IMessageError or one of its subclasses. First branch by error class with instanceof, then use error.code for the exact reason.
Do not parse error.message for program logic. message is useful for logs and user-facing text. Use error.code, error.retryable, and error.context for decisions.
What You Can Do
Handle Errors
Check the most specific subclasses first, and handleIMessageError last. If the error is not from the SDK, rethrow it.
Error Object
All SDK errors include these fields:Common Error Codes
ErrorCode is both a runtime object and a TypeScript type. In most code, check the specific error class first, then compare error.code:
gRPC Status Mapping
Most application code should not branch ongrpcCode. Prefer error classes and error.code. Use this table when debugging transport-level behavior.
Retries
Setretry when creating the client. The SDK retries retryable unary requests automatically. Invalid input, missing resources, and permission failures do not become valid by retrying the same request.
RetryOptions:
Idempotency
Most calls do not needclientMessageId. Use it only when your queue or worker may rerun the same logical write after a crash or timeout. Automatic retry handles the same SDK call. clientMessageId handles your business job starting the same write again.
Use the same clientMessageId every time you retry the same logical write:
Next Steps
- Events — recover after stream disconnects
- Messages — understand write methods, idempotency keys, and message errors
- Attachments — handle
attachmentNotReady