File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 7
7
use ApiSkeletons \Laravel \ApiProblem \Exception \InvalidArgumentException ;
8
8
use ApiSkeletons \Laravel \ApiProblem \Exception \ProblemExceptionInterface ;
9
9
use Exception ;
10
+ use Illuminate \Http \Response ;
10
11
use Throwable ;
11
12
12
13
use function array_key_exists ;
17
18
use function get_class ;
18
19
use function in_array ;
19
20
use function is_numeric ;
21
+ use function response ;
20
22
use function sprintf ;
21
23
use function strtolower ;
22
24
use function trim ;
@@ -213,6 +215,16 @@ public function toArray(): array
213
215
return array_merge ($ this ->additionalDetails , $ problem );
214
216
}
215
217
218
+ /**
219
+ * Compose a response and return it.
220
+ */
221
+ public function response (): Response
222
+ {
223
+ return response ()
224
+ ->setStatusCode ($ this ->getStatus ())
225
+ ->setContent ($ this ->toArray ());
226
+ }
227
+
216
228
/**
217
229
* Set the flag indicating whether an exception detail should include a
218
230
* stack trace and previous exception information.
You can’t perform that action at this time.
0 commit comments