Actions

API16

JError/setErrorHandling

From Joomla! Documentation

< API16:JError
Revision as of 23:05, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

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

static 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

public static function setErrorHandling($level, $mode, $options = null)
{
        $levels = 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
                JError::$handlers[$eLevel] = array ('mode' => $mode);
                if ($options != null) {
                        JError::$handlers[$eLevel]['options'] = $options;
                }
        }
 
        return true;
}

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

Examples

<CodeExamplesForm />