diff --git a/src/php_error.php b/src/php_error.php index fa55cd5..64b0492 100644 --- a/src/php_error.php +++ b/src/php_error.php @@ -1135,6 +1135,8 @@ public static function identifyTypeHTML( $arg, $recurseLevels=1 ) { private $classNotFoundException; + private $throwErrors; + /** * = Options = * @@ -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). */ @@ -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; @@ -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;