API15

JError/setErrorHandling

< API15:JError

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

Method to set the way the JError will handle different error levels. Use this if you want to override the default settings.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

setErrorHandling($level, $mode, $options=null)
Parameter Name Default Value Description
$level $level The error level for which to set the error handling
$mode $mode The mode to use for the error handling.
$options null $options Optional: Any options needed for the given mode.

Returns

mixed True on success, or a object if failed.

Defined in

libraries/joomla/error/error.php

Importing

jimport( 'joomla.error.error' );

Source Body

function setErrorHandling($level, $mode, $options = null)
{
        $levels = $GLOBALS['_JERROR_LEVELS'];

        $function = 'handle'.ucfirst($mode);
        if (!is_callable(array ('JError',$function))) {
                return JError::raiseError(E_ERROR, 'JError:'.JERROR_ILLEGAL_MODE, 'Error Handling mode is not known', 'Mode: '.$mode.' is not implemented.');
        }

        foreach ($levels as $eLevel => $eTitle) {
                if (($level & $eLevel) != $eLevel) {
                        continue;
                }

                // set callback options
                if ($mode == 'callback') {
                        if (!is_array($options)) {
                                return JError::raiseError(E_ERROR, 'JError:'.JERROR_ILLEGAL_OPTIONS, 'Options for callback not valid');
                        }

                        if (!is_callable($options)) {
                                $tmp = array ('GLOBAL');
                                if (is_array($options)) {
                                        $tmp[0] = $options[0];
                                        $tmp[1] = $options[1];
                                } else {
                                        $tmp[1] = $options;
                                }

                                return JError::raiseError(E_ERROR, 'JError:'.JERROR_CALLBACK_NOT_CALLABLE, 'Function is not callable', 'Function:'.$tmp[1].' scope '.$tmp[0].'.');
                        }
                }

                // save settings
                $GLOBALS['_JERROR_HANDLERS'][$eLevel] = array ('mode' => $mode);
                if ($options != null) {
                        $GLOBALS['_JERROR_HANDLERS'][$eLevel]['options'] = $options;
                }
        }

        return true;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

Code Examples


Advertisement