File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55use Brainstud \JsonApi \Exceptions \BadRequestJsonApiException ;
66use Brainstud \JsonApi \Exceptions \JsonApiExceptionInterface ;
7+ use Brainstud \JsonApi \Exceptions \MethodNotAllowedJsonApiException ;
78use Brainstud \JsonApi \Exceptions \NotFoundJsonApiException ;
89use Brainstud \JsonApi \Responses \ErrorResponse ;
910use Brainstud \JsonApi \Responses \Errors \DefaultError ;
1415use Illuminate \Validation \ValidationException ;
1516use RuntimeException ;
1617use Symfony \Component \HttpKernel \Exception \HttpExceptionInterface ;
18+ use Symfony \Component \HttpKernel \Exception \MethodNotAllowedHttpException ;
19+ use Symfony \Component \Routing \Exception \MethodNotAllowedException ;
1720use Throwable ;
1821
1922/**
@@ -48,6 +51,14 @@ public function register(): void
4851 ))->withErrorName ('LAZY_LOADING_VIOLATION ' );
4952 });
5053
54+ $ this ->map (function (MethodNotAllowedHttpException |MethodNotAllowedException $ exception ) {
55+ return (new MethodNotAllowedJsonApiException (
56+ message: $ exception ->getMessage (),
57+ previous: $ exception ->getPrevious (),
58+ code: $ exception ->getCode (),
59+ ))->withErrorName ('METHOD_NOT_ALLOWED ' );
60+ });
61+
5162 $ this ->renderable (function (JsonApiExceptionInterface $ exception ) {
5263 return ErrorResponse::make ([new DefaultError (
5364 (isset ($ exception ->errorName ) ? $ exception ->errorName : '' ),
You can’t perform that action at this time.
0 commit comments