File tree Expand file tree Collapse file tree 3 files changed +22
-17
lines changed Expand file tree Collapse file tree 3 files changed +22
-17
lines changed Original file line number Diff line number Diff line change 6565 | Restify Exception Handler
6666 |--------------------------------------------------------------------------
6767 |
68- | These will override the main application exception handler,
69- | set to null, it will not override it.
70- | Having RestifyHandler as a global exception handler is a good approach, since it
68+ | The exception handler will be attached to any Restify "CRUD" route.
69+ | It will not be attached to custom routes defined in yours Restify Repositories,
70+ | if you want to have it for all of the routes, can extend RestifyHandler
71+ | from your application App\Exceptions\Handler.
72+ |
73+ | These will override the main application exception handler, set to null, it will not override it.
74+ | Having RestifyHandler as a global exception handler is a good recommendation since it
7175 | will return the exceptions in an API pretty format.
76+ |
7277 */
7378 'exception_handler ' => \Binaryk \LaravelRestify \Exceptions \RestifyHandler::class,
7479];
Original file line number Diff line number Diff line change 22
33namespace Binaryk \LaravelRestify ;
44
5- use Illuminate \Contracts \Debug \ExceptionHandler ;
65use Illuminate \Support \Facades \Gate ;
76use Illuminate \Support \ServiceProvider ;
87
@@ -14,7 +13,6 @@ class RestifyApplicationServiceProvider extends ServiceProvider
1413 public function boot ()
1514 {
1615 $ this ->authorization ();
17- $ this ->registerExceptionHandler ();
1816 $ this ->repositories ();
1917 }
2018
@@ -32,18 +30,6 @@ protected function repositories()
3230 Restify::repositoriesFrom (app_path ('Restify ' ));
3331 }
3432
35- /**
36- * Register Restify's custom exception handler.
37- *
38- * @return void
39- */
40- protected function registerExceptionHandler ()
41- {
42- if (config ('restify.exception_handler ' ) && class_exists (value (config ('restify.exception_handler ' )))) {
43- $ this ->app ->bind (ExceptionHandler::class, value (config ('restify.exception_handler ' )));
44- }
45- }
46-
4733 /**
4834 * Configure the Restify authorization services.
4935 *
Original file line number Diff line number Diff line change 22
33namespace Binaryk \LaravelRestify ;
44
5+ use Illuminate \Contracts \Debug \ExceptionHandler ;
56use Illuminate \Support \Facades \Route ;
67use Illuminate \Support \ServiceProvider ;
78
@@ -17,6 +18,7 @@ class RestifyServiceProvider extends ServiceProvider
1718 public function boot ()
1819 {
1920 $ this ->registerRoutes ();
21+ $ this ->registerExceptionHandler ();
2022 }
2123
2224 /**
@@ -48,4 +50,16 @@ public function defaultRoutes($config)
4850
4951 return $ this ;
5052 }
53+
54+ /**
55+ * Register Restify's custom exception handler.
56+ *
57+ * @return void
58+ */
59+ protected function registerExceptionHandler ()
60+ {
61+ if (config ('restify.exception_handler ' ) && class_exists (value (config ('restify.exception_handler ' )))) {
62+ $ this ->app ->bind (ExceptionHandler::class, value (config ('restify.exception_handler ' )));
63+ }
64+ }
5165}
You can’t perform that action at this time.
0 commit comments