Actions

API16

JError/setErrorHandling

From Joomla! Documentation

< API16:JError
Revision as of 17:44, 22 March 2010 by Doxiki (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.

Contents

Description

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

[Edit Descripton]

Description:JError/setErrorHandling

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;
}

[Edit See Also] SeeAlso:JError/setErrorHandling

Examples

<CodeExamplesForm />