44
55namespace SimpleAsFuck \ApiToolkit \Data \Client ;
66
7- use SimpleAsFuck \ApiToolkit \DataObject \Common \ProblemDetail ;
7+ use SimpleAsFuck \ApiToolkit \Data \Common \ProblemDetail ;
88use SimpleAsFuck \ApiToolkit \Model \Client \Request ;
99use SimpleAsFuck \ApiToolkit \Model \Client \Response ;
1010use SimpleAsFuck \Validator \Rule \Object \ObjectRule ;
1111
1212class ApiException extends \RuntimeException
1313{
14+ private readonly ?ProblemDetail $ problemDetail ;
15+
1416 /**
1517 * @param string $message for logging or debugging purposes MUST contain only English message
1618 * @param int $code https://datatracker.ietf.org/doc/html/rfc9457#name-status or HTTP status
@@ -21,11 +23,28 @@ public function __construct(
2123 int $ code ,
2224 private readonly Request $ request ,
2325 private readonly ?Response $ response ,
24- private readonly ?ProblemDetail $ problemDetail ,
26+ /** @phpstan-ignore-next-line */
27+ ProblemDetail |\SimpleAsFuck \ApiToolkit \DataObject \Common \ProblemDetail |null $ problemDetail ,
2528 private readonly ?ObjectRule $ problemDetailExtensions ,
2629 ?\Throwable $ previous = null
2730 ) {
2831 parent ::__construct ($ message , $ code , $ previous );
32+
33+ if ($ problemDetail instanceof \SimpleAsFuck \ApiToolkit \DataObject \Common \ProblemDetail) {
34+ $ problemDetail = new ProblemDetail (
35+ /** @phpstan-ignore-next-line */
36+ $ problemDetail ->type ,
37+ /** @phpstan-ignore-next-line */
38+ $ problemDetail ->status ,
39+ /** @phpstan-ignore-next-line */
40+ $ problemDetail ->title ,
41+ /** @phpstan-ignore-next-line */
42+ $ problemDetail ->detail ,
43+ /** @phpstan-ignore-next-line */
44+ $ problemDetail ->instance ,
45+ );
46+ }
47+ $ this ->problemDetail = $ problemDetail ;
2948 }
3049
3150 public function getRequest (): Request
0 commit comments