Tobscure\JsonApi\ErrorHandler::registerHandler PHP Method

registerHandler() public method

Register a new exception handler.
public registerHandler ( Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface $handler ) : void
$handler Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface
return void
    public function registerHandler(ExceptionHandlerInterface $handler)
    {
        $this->handlers[] = $handler;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function register()
 {
     $this->app->singleton(UrlGenerator::class, function () {
         return new UrlGenerator($this->app, $this->app->make('flarum.api.routes'));
     });
     $this->app->singleton('flarum.api.routes', function () {
         return $this->getRoutes();
     });
     $this->app->singleton(ErrorHandler::class, function () {
         $handler = new ErrorHandler();
         $handler->registerHandler(new Handler\FloodingExceptionHandler());
         $handler->registerHandler(new Handler\IlluminateValidationExceptionHandler());
         $handler->registerHandler(new Handler\InvalidConfirmationTokenExceptionHandler());
         $handler->registerHandler(new Handler\ModelNotFoundExceptionHandler());
         $handler->registerHandler(new Handler\PermissionDeniedExceptionHandler());
         $handler->registerHandler(new Handler\ValidationExceptionHandler());
         $handler->registerHandler(new InvalidParameterExceptionHandler());
         $handler->registerHandler(new FallbackExceptionHandler($this->app->inDebugMode()));
         return $handler;
     });
 }