Exception handling features¶
The Suite Framework provides features to handle exceptions that occurs in the ASP.NET Core execution pipeline gracefully.
The implementation adheres to the
RFC7807 - Problem Details for HTTP APIs,
which uses a ProblemDetails
object to wrap up the exception coming from the
underlying execution pipeline.
By using this feature the developer gets always a consistent error representation, no matter what kind of exception was raised by the upstream ASP.NET Core processing pipeline.
Unique identifiers¶
To have a better compliance with the RFC7807, each exception type must have an
unique identifier, so that client applications can uniquely differentiate them,
and take specific actions based on it. This identifier is mapped to the Type
attribute of the ProblemDetails
error instance, this type must be a valid
Uri
type.
The Suite Framework will automatically generate the Type
based on
configurable base Uri
plus the exception type. The resulting Type
looks
like:
JSON | |
---|---|
The Base Url
for the exception type construction can be configured by setting
the desired value to the exception handling module options
ProblemDetailsTypeBaseUri
property.
Note
This Base Url will most likely be configured on a host or global basis and you do not need to worry about it.
Exceptions providing Code¶
Some exceptions define a Code
attribute to provide more information about the
exception, such as BusinessException
. For any exception implementing
IHasErrorCode
the Code
attribute will be mapped as suffix for the Type
attribute of the ProblemDetails
entity as we have seen right before.
JSON | |
---|---|
Localizable title and detail¶
The Suite Framework allow us to make the exceptions localizable, not only the message but the details as well.
Extra data¶
Following the recommendations of the RFC, the exceptions can provide extra
data regarding the error or the context in which the exception has been thrown.
Any extra data value supplied with the exception will be pushed into the
resulting ProblemDetails
error object. The following example shows the extra
data attributes.
Detailed error information in development environment¶
In development environment the Suite Framework will supply the detailed
exception information in the ErrorDetail
attribute of the resulting
ProblemDetail
error object.