ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Slim\Handlers\AbstractError Class Reference

Abstract Slim application error handler. More...

+ Inheritance diagram for Slim\Handlers\AbstractError:
+ Collaboration diagram for Slim\Handlers\AbstractError:

Public Member Functions

 __construct ($displayErrorDetails=false)
 Constructor. More...
 

Protected Member Functions

 writeToErrorLog ($throwable)
 Write to the error log if displayErrorDetails is false. More...
 
 renderThrowableAsText ($throwable)
 Render error as Text. More...
 
 logError ($message)
 Wraps the error_log function so that this can be easily tested. More...
 
- Protected Member Functions inherited from Slim\Handlers\AbstractHandler
 determineContentType (ServerRequestInterface $request)
 Determine which content type we know about is wanted using Accept header. More...
 

Protected Attributes

 $displayErrorDetails
 
- Protected Attributes inherited from Slim\Handlers\AbstractHandler
 $knownContentTypes
 

Detailed Description

Abstract Slim application error handler.

Definition at line 14 of file AbstractError.php.

Constructor & Destructor Documentation

◆ __construct()

Slim\Handlers\AbstractError::__construct (   $displayErrorDetails = false)

Constructor.

Parameters
bool$displayErrorDetailsSet to true to display full details

Definition at line 26 of file AbstractError.php.

27 {
28 $this->displayErrorDetails = (bool) $displayErrorDetails;
29 }

References Slim\Handlers\AbstractError\$displayErrorDetails.

Member Function Documentation

◆ logError()

Slim\Handlers\AbstractError::logError (   $message)
protected

Wraps the error_log function so that this can be easily tested.

Parameters
$message

Definition at line 95 of file AbstractError.php.

96 {
98 }
catch(Exception $e) $message

References $message, and Monolog\Handler\error_log().

Referenced by Slim\Handlers\AbstractError\writeToErrorLog().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderThrowableAsText()

Slim\Handlers\AbstractError::renderThrowableAsText (   $throwable)
protected

Render error as Text.

Parameters
\Exception | \Throwable$throwable
Returns
string

Definition at line 63 of file AbstractError.php.

64 {
65 $text = sprintf('Type: %s' . PHP_EOL, get_class($throwable));
66
67 if ($code = $throwable->getCode()) {
68 $text .= sprintf('Code: %s' . PHP_EOL, $code);
69 }
70
71 if ($message = $throwable->getMessage()) {
72 $text .= sprintf('Message: %s' . PHP_EOL, htmlentities($message));
73 }
74
75 if ($file = $throwable->getFile()) {
76 $text .= sprintf('File: %s' . PHP_EOL, $file);
77 }
78
79 if ($line = $throwable->getLine()) {
80 $text .= sprintf('Line: %s' . PHP_EOL, $line);
81 }
82
83 if ($trace = $throwable->getTraceAsString()) {
84 $text .= sprintf('Trace: %s', $trace);
85 }
86
87 return $text;
88 }
PHP_EOL
Definition: complexTest.php:7
$code
Definition: example_050.php:99
$text
Definition: errorreport.php:18

References $code, $message, $text, and PHP_EOL.

Referenced by Slim\Handlers\AbstractError\writeToErrorLog().

+ Here is the caller graph for this function:

◆ writeToErrorLog()

Slim\Handlers\AbstractError::writeToErrorLog (   $throwable)
protected

Write to the error log if displayErrorDetails is false.

Parameters
\Exception | \Throwable$throwable
Returns
void

Definition at line 38 of file AbstractError.php.

39 {
40 if ($this->displayErrorDetails) {
41 return;
42 }
43
44 $message = 'Slim Application Error:' . PHP_EOL;
45 $message .= $this->renderThrowableAsText($throwable);
46 while ($throwable = $throwable->getPrevious()) {
47 $message .= PHP_EOL . 'Previous error:' . PHP_EOL;
48 $message .= $this->renderThrowableAsText($throwable);
49 }
50
51 $message .= PHP_EOL . 'View in rendered output by enabling the "displayErrorDetails" setting.' . PHP_EOL;
52
53 $this->logError($message);
54 }
logError($message)
Wraps the error_log function so that this can be easily tested.
renderThrowableAsText($throwable)
Render error as Text.

References $message, Slim\Handlers\AbstractError\logError(), PHP_EOL, and Slim\Handlers\AbstractError\renderThrowableAsText().

Referenced by Slim\Handlers\Error\__invoke(), and Slim\Handlers\PhpError\__invoke().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $displayErrorDetails

Slim\Handlers\AbstractError::$displayErrorDetails
protected

Definition at line 19 of file AbstractError.php.

Referenced by Slim\Handlers\AbstractError\__construct().


The documentation for this class was generated from the following file: