Create a new ConnectError. If no code is provided, code "unknown" is used. Outgoing details are only relevant for the server side - a service may raise an error with details, and it is up to the protocol implementation to encode and send the details along with error.
Optional
code: CodeOptional
metadata: HeadersInitOptional
outgoingDetails: Message<AnyMessage>[]Optional
cause: unknownThe underlying cause of this error, if any. In cases where the actual cause is elided with the error message, the cause is specified here so that we don't leak the underlying error, but instead make it available for logging.
Readonly
codeThe Code for this error.
When an error is parsed from the wire, incoming error details are stored in this property. They can be retrieved using findDetails().
When an error is constructed to be sent over the wire, outgoing error details are stored in this property as well.
Readonly
metadataA union of response headers and trailers associated with this error.
Readonly
rawThe error message, but without a status code in front.
For example, a new ConnectError("hello", Code.NotFound)
will have
the message [not found] hello
, and the rawMessage hello
.
Optional
stackStatic
Optional
prepareOptional override for formatting stack traces
Static
stackRetrieve error details from a ConnectError. On the wire, error details are wrapped with google.protobuf.Any, so that a server or middleware can attach arbitrary data to an error. This function decodes the array of error details from the ConnectError object, and returns an array with the decoded messages. Any decoding errors are ignored, and the detail will simply be omitted from the list.
Static
captureStatic
fromConvert any value - typically a caught error into a ConnectError, following these rules:
Optional
code: CodeGenerated using TypeDoc
ConnectError captures four pieces of information: a Code, an error message, an optional cause of the error, and an optional collection of arbitrary Protobuf messages called "details".
Because developer tools typically show just the error message, we prefix it with the status code, so that the most important information is always visible immediately.
Error details are wrapped with google.protobuf.Any on the wire, so that a server or middleware can attach arbitrary data to an error. Use the method findDetails() to retrieve the details.