CipherStashDocs
StackLatestPackagesStackSrcErrorsType aliases

StackError

Discriminated union of all specific error types. Use `StackError` when you need exhaustive error handling via `switch` on the `type` field.

@cipherstash/stack


Type Alias: StackError

type StackError = 
  | ClientInitError
  | EncryptionOperationError
  | DecryptionOperationError
  | LockContextError
  | CtsTokenError;

Defined in: packages/stack/src/errors/index.ts:98

Discriminated union of all specific error types.

Use StackError when you need exhaustive error handling via switch on the type field.

Example

function handleError(error: StackError) {
  switch (error.type) {
    case 'ClientInitError':
      // re-initialize client
      break
    case 'EncryptionError':
    case 'DecryptionError':
      // log and retry
      break
    case 'LockContextError':
      // re-authenticate
      break
    case 'CtsTokenError':
      // refresh token
      break
    default:
      error satisfies never
  }
}

On this page