createDecodeFault
Builds a decode fault for a response that arrived but could not be read as declared.
@defjs/core · Function
Signature
function createDecodeFault( code: DecodeFaultCode, cause: unknown, response: HttpMeta, ): DecodeFault;
code is RES_DECODE_FAILED, RES_MEDIA_TYPE_INVALID, or
RES_STRUCT_MISMATCH. The fault carries metadata only: a body is a decoded
value, and decoding is what failed, so there is no body. status is copied
from response. The result is a native Error named DefjsFault.
cause is the underlying parser or struct failure and is kept as cause.
Its message normally becomes the fault message (String(cause) when it is
not an Error). For RES_DECODE_FAILED with an Error named SyntaxError,
the message is Response body could not be decoded, so String(fault) does
not include a body fragment. Default Struct messages contain received kinds,
not values; raw values and parser text remain on the cause.
Parameters
Prop
Type
code DecodeFaultCodeWhich read step failed.
cause unknownUnderlying parser or struct failure.
response HttpMetaMetadata of the response that could not be read.
Returns
A decode fault with no body.