File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,4 +144,17 @@ public function it_should_deal_with_string_exception_codes(): void
144144 'detail ' => $ message ,
145145 ]);
146146 }
147+
148+ public function it_should_use_code_as_status_code_when_valid_http_status_code_error (): void
149+ {
150+ $ message = 'an honest error ' ;
151+ $ this ->beConstructedWith (new \InvalidArgumentException ($ message , 400 ));
152+
153+ $ this ->toArray ()->shouldBe ([
154+ 'status ' => 400 ,
155+ 'type ' => HttpApiProblem::TYPE_HTTP_RFC ,
156+ 'title ' => HttpApiProblem::getTitleForStatusCode (400 ),
157+ 'detail ' => $ message ,
158+ ]);
159+ }
147160}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public function __construct(Throwable $exception)
1818 {
1919 $ this ->exception = $ exception ;
2020 $ exceptionCode = $ exception ->getCode ();
21- $ statusCode = is_int ($ exception ) && $ exceptionCode >= 400 && $ exceptionCode <= 599
21+ $ statusCode = is_int ($ exceptionCode ) && $ exceptionCode >= 400 && $ exceptionCode <= 599
2222 ? $ exceptionCode
2323 : 500 ;
2424
You can’t perform that action at this time.
0 commit comments