Example #1
0
 public function registerRouting(Container $container, ApplicationServiceProvider $builder)
 {
     $container['errorHandler.badRequest'] = function () {
         return new ErrorHandler('error.badRequest', 400, 'Bad Request');
     };
     $container['errorHandler.unauthorized'] = function () {
         return new ErrorHandler('error.unauthorized', 401, 'Unauthorized');
     };
     $container['errorHandler.notFound'] = function () {
         return new ErrorHandler('error.notFound', 404, 'Not Found');
     };
     $container['errorHandler.serverError'] = function () {
         return new ErrorHandler('error.serverError', 500, 'Server Error');
     };
     // Add error handlers
     $builder->addExecutor('error.unauthorized', 'errorHandler.unauthorized');
     $builder->addGenerator('error.unauthorized', self::JSON_API_CT, 'errorHandler.unauthorized');
     $builder->addExecutor('error.badRequest', 'errorHandler.badRequest');
     $builder->addGenerator('error.badRequest', self::JSON_API_CT, 'errorHandler.badRequest');
     $builder->addExecutor('error.notFound', 'errorHandler.notFound');
     $builder->addGenerator('error.notFound', self::JSON_API_CT, 'errorHandler.notFound');
     $builder->addExecutor('error.serverError', 'errorHandler.serverError');
     $builder->addGenerator('error.serverError', self::JSON_API_CT, 'errorHandler.serverError');
 }