On this page
- Since 1.1.0.
When you raise your own exceptions implementing
you will always be in control of all the properties returned as part of the
response payload, including the
However, there are some use cases in which this library will have to infer some of those values.
The main situations in which this can happen are:
- When an exception not implementing
ProblemDetailsExceptionInterfaceis captured by the
- When the
In these two cases, the
type properties will be inferred from the
status code, which will usually be
500 in the first case and
404 in the
To be more precise, the
ProblemDetailsMiddlewarewill use the exception's error code when
Because of this, in any of those cases, you will end up with values like
https://httpstatus.es/500 for the
Configuring custom default types
type property will usually be used by API consumers to uniquely
identify an error, you might want to be able to provide your own custom values
In order to do that, this library lets you configure the default
type value to
be used for every status code when some of the cases listed above happens.
return [ 'problem-details' => [ 'default_types_map' => [ 404 => 'https://example.com/problem-details/error/not-found', 500 => 'https://example.com/problem-details/error/internal-server-error', ], ], ];
If this configuration is found, it will be consumed by the
and your custom values will be used when the
type was not explicitly provided.
Found a mistake or want to contribute to the documentation? Edit this page on GitHub!