Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/php_error.php
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ public static function identifyTypeHTML( $arg, $recurseLevels=1 ) {

private $classNotFoundException;

private $throwErrors;

/**
* = Options =
*
Expand Down Expand Up @@ -1189,6 +1191,9 @@ public static function identifyTypeHTML( $arg, $recurseLevels=1 ) {
* pages too, such as replying with images of JavaScript
* from your PHP. Defaults to true.
*
* - throw_errors By default, PHP Error will stop execution on trigerred errors.
* You can enabled it to throw errors instead.
*
* @param options Optional, an array of values to customize this handler.
* @throws Exception This is raised if given an options that does *not* exist (so you know that option is meaningless).
*/
Expand Down Expand Up @@ -1249,6 +1254,8 @@ public function __construct( $options=null ) {
$this->displayLineNumber = ErrorHandler::optionsPop( $options, 'display_line_numbers' , false );

$this->htmlOnly = !! ErrorHandler::optionsPop( $options, 'html_only', true );

$this->throwErrors = !! ErrorHandler::optionsPop( $options, 'throw_errors', false );

$this->classNotFoundException = null;

Expand Down Expand Up @@ -2645,8 +2652,11 @@ function( $code, $message, $file, $line, $context ) use ( $self, &$catchSurpress
*/
if ( error_reporting() !== 0 || $catchSurpressedErrors ) {
$ex = new ErrorException( $message, $code, $code, $file, $line );

$self->reportException( $ex );
if ($self->throwErrors) {
throw $ex;
} else {
$self->reportException( $ex );
}
}
} else {
return false;
Expand Down