/** * Create an ExceptionResolver and attach a set of useful exception handlers * for HTTP apps. * @return ExceptionResolver * @throws TierException */ public function createStandardExceptionResolver() { $exceptionResolver = new ExceptionResolver(); $exceptionResolver->addExceptionHandler('Jig\\JigException', 'Tier\\processJigException', ExceptionResolver::ORDER_MIDDLE); $exceptionResolver->addExceptionHandler('Auryn\\InjectorException', 'Tier\\processInjectorException', ExceptionResolver::ORDER_LAST - 2); $exceptionResolver->addExceptionHandler('Auryn\\InjectionException', 'Tier\\processInjectionException', ExceptionResolver::ORDER_MIDDLE); $exceptionResolver->addExceptionHandler('Exception', 'Tier\\processException', ExceptionResolver::ORDER_LAST); return $exceptionResolver; }
/** * Create an ExceptionResolver and attach a set of useful exception handlers * for HTTP apps. * @return ExceptionResolver * @throws TierException */ public function createStandardExceptionResolver() { $exceptionResolver = new ExceptionResolver(); // Create the exception handlers. More generic exceptions // are placed later in the order, so as to allow the more // specific exception handlers to handle exceptions. $exceptionResolver->addExceptionHandler('Jig\\JigException', ['Tier\\Tier', 'processJigException'], ExceptionResolver::ORDER_MIDDLE); $exceptionResolver->addExceptionHandler('Auryn\\InjectionException', ['Tier\\Tier', 'processInjectionException'], ExceptionResolver::ORDER_MIDDLE); $exceptionResolver->addExceptionHandler('Auryn\\InjectorException', ['Tier\\Tier', 'processInjectorException'], ExceptionResolver::ORDER_LAST - 2); // This will only be triggered on PHP 7 $exceptionResolver->addExceptionHandler('Throwable', ['Tier\\Tier', 'processThrowable'], ExceptionResolver::ORDER_LAST); // This will only be triggered on PHP 5.6 $exceptionResolver->addExceptionHandler('Exception', ['Tier\\Tier', 'processException'], ExceptionResolver::ORDER_LAST); return $exceptionResolver; }
public function testExceptionResolverError() { $exceptionResolver = new ExceptionResolver(); $fn = function () { }; $this->setExpectedException('Tier\\TierException'); $exceptionResolver->addExceptionHandler('FooException', $fn, -10); }