public function test_enable_exception_handling() { $errorHandler = new ErrorHandler(); $monologErrorHandler = new MonologErrorHandler($this->createLogger(), $errorHandler); $this->assertEquals(0, count($errorHandler->getExceptionHandlers())); $monologErrorHandler->enableExceptionHandling(); $this->assertEquals(1, count($errorHandler->getExceptionHandlers())); }
public function test_enable_exception_handling() { $errorHandler = new ErrorHandler(); $bugsnagErrorHandler = new BugsnagErrorHandler(new Bugsnag_Client('client_id'), $errorHandler); $this->assertEquals(0, count($errorHandler->getExceptionHandlers())); $bugsnagErrorHandler->enableExceptionHandling(); $this->assertEquals(1, count($errorHandler->getExceptionHandlers())); }
public function test_convert_error_to_exception_and_call_handler_and_handle_exception() { $converter = new ErrorConverter(); $handler = new ErrorHandler(true); $handler->addExceptionHandler(function (ErrorException $ex) { return true; }); $error = new RecoverableError(ErrorType::ERROR, 'foo', 'bar', 'yolo'); $converter->convertErrorToExceptionAndCallHandler($handler, $error); }
<?php use Weew\ErrorHandler\ErrorHandler; use Weew\ErrorHandler\ErrorType; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(); $errorHandler->enableRecoverableErrorHandling(); $errorHandler->addRecoverableErrorHandler(function () { echo 'handled recoverable '; return true; }); trigger_error('error', ErrorType::USER_ERROR); echo 'continue';
<?php use Weew\ErrorHandler\ErrorHandler; use Weew\ErrorHandler\ErrorType; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(true); $errorHandler->enableRecoverableErrorHandling(); $errorHandler->enableExceptionHandling(); trigger_error('error', ErrorType::USER_ERROR); echo 'continue';
<?php use Weew\ErrorHandler\ErrorHandler; use Weew\ErrorHandler\ErrorType; use Weew\ErrorHandler\Exceptions\UserErrorException; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(true); $errorHandler->enableFatalErrorHandling(); $errorHandler->enableExceptionHandling(); $errorHandler->addExceptionHandler(function (UserErrorException $ex) { echo 'handled fatal converted'; return true; }); trigger_error('error', ErrorType::USER_ERROR);
<?php use Weew\ErrorHandler\ErrorHandler; use Weew\ErrorHandler\ErrorType; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(); $errorHandler->enableFatalErrorHandling(); $errorHandler->addFatalErrorHandler(function () { echo 'handled fatal'; return true; }); trigger_error('error', ErrorType::FOO);
<?php use Weew\ErrorHandler\ErrorHandler; use Weew\ErrorHandler\ErrorType; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(true); $errorHandler->enableFatalErrorHandling(); $errorHandler->enableExceptionHandling(); trigger_error('error', ErrorType::USER_ERROR);
<?php use Weew\ErrorHandler\ErrorHandler; use Weew\ErrorHandler\ErrorType; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(); $errorHandler->enableRecoverableErrorHandling(); trigger_error('error', ErrorType::USER_ERROR); echo 'continue';
public function test_exception_from_recoverable_error_handler_is_handled() { $handler = new ErrorHandler(); $recoverableError = new RecoverableError(ErrorType::ERROR, 'foo', 'bar', 'baz'); $handler->addRecoverableErrorHandler(function (IError $error) { throw new Exception(); }); try { $handler->handleRecoverableError($recoverableError); } catch (Exception $ex) { } }
<?php use Tests\Weew\ErrorHandler\Stubs\FooException; use Weew\ErrorHandler\ErrorHandler; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(); $errorHandler->enableExceptionHandling(); $errorHandler->addExceptionHandler(function (FooException $ex) { echo 'handled exception'; return true; }); throw new FooException();
<?php use Tests\Weew\ErrorHandler\Stubs\FooException; use Weew\ErrorHandler\ErrorHandler; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(); $errorHandler->enableExceptionHandling(); throw new FooException();
<?php use Weew\ErrorHandler\ErrorHandler; use Weew\ErrorHandler\ErrorType; use Weew\ErrorHandler\Exceptions\UserErrorException; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(true); $errorHandler->enableRecoverableErrorHandling(); $errorHandler->enableExceptionHandling(); $errorHandler->addExceptionHandler(function (UserErrorException $ex) { echo 'handled recoverable converted '; return true; }); trigger_error('error', ErrorType::USER_ERROR); echo 'continue';
<?php use Weew\ErrorHandler\ErrorHandler; use Weew\ErrorHandler\ErrorType; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(); $errorHandler->enableFatalErrorHandling(); trigger_error('error', ErrorType::USER_ERROR);