API16

JError/throwError: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{Description:JError/throwError}} ...
 
m preparing for archive only
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<! removed transcluded page call, red link never existed >
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JError/throwError|Edit Descripton]]<nowiki>]</nowiki>
</span>
 
{{Description:JError/throwError}}


===Syntax===
===Syntax===
Line 15: Line 10:
!Description
!Description
|-
|-
|  
| &$exception
|  
|  
|   
|   
Line 64: Line 59:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JError/throwError|Edit See Also]]<nowiki>]</nowiki>
<! removed transcluded page call, red link never existed >
</span>
{{SeeAlso:JError/throwError}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=throwError
  category=throwError
  category=JError
  category=JError
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API16]]

Latest revision as of 01:37, 25 March 2017

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

Syntax

static throwError(&$exception)
Parameter Name Default Value Description
&$exception

Defined in

libraries/joomla/error/error.php

Importing

jimport( 'joomla.error.error' );

Source Body

public static function throwError(&$exception)
{
        static $thrown = false;

        // If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!
        if ($thrown)
        {
                //echo debug_print_backtrace();
                jexit('Infinite loop detected in JError');
        }

        $thrown = true;
        $level = $exception->get('level');

        // see what to do with this kind of error
        $handler = JError::getErrorHandling($level);

        $function = 'handle'.ucfirst($handler['mode']);
        if (is_callable(array('JError', $function))) {
                $reference = &call_user_func_array(array('JError',$function), array(&$exception, (isset($handler['options'])) ? $handler['options'] : array()));
        }
        else {
                // This is required to prevent a very unhelpful white-screen-of-death
                jexit(
                        'JError::raise -> Static method JError::' . $function . ' does not exist.' .
                        ' Contact a developer to debug' .
                        '<br /><strong>Error was</strong> ' .
                        '<br />' . $exception->getMessage()
                );
        }
        //we don't need to store the error, since JException already does that for us!
        //remove loop check
        $thrown = false;
        return $reference;
}


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

Examples

Code Examples