Smithy Server Generator for TypeScript error handling#
Errors are structures associated with services and operations in the Smithy model and are used to indicate that the
server encountered a problem during request processing. Structures with the error trait are code generated as subclasses
If a code-generated
Error is thrown from a handler implementation, and the
Error is associated with the
operation or service in the model, then the server SDK will serialize the Error according to the rules of the protocol.
For instance, HTTP binding protocols set the status code of the response based on the
If a non-code-generated Error, or a code-generated Error that is not associated with the operation or service in the
model, is thrown from a handler, then a synthetic
InternalFailure will be rendered as the result instead.
Synthetic errors are errors that are not included in the Smithy model, but can still be thrown by the server SDK. In general, these errors are not expected to have corresponding code generated types on the client side. These errors fall into two categories: framework-level errors that are unavoidable, and errors that are associated with the low-level transport protocol, such as HTTP.
For backwards compatibility purposes, the names of synthetic errors generally end with
UnsupportedMediaTypeException represents HTTP error 415, returned when a request has a
Content-Type that is not
accepted for the protocol or does not match the
@mediaType trait in the model.
NotAcceptableException represents HTTP error 406, returned when a request's
Accept header does not match the type used
to serialize protocol responses, or when it does not match the response payload's