← Public packages
@cameronpak/zo-computer
Typed Zo Computer API client with Result-based error handling and SSE streaming.
src/errors.ts
67 lines · 1.4 KB · TypeScriptimport { TaggedError } from 'better-result'
/**
* The caller gave the client something it cannot use.
*
* Raised before any network call happens.
*/
export class ZoConfigError extends TaggedError('ZoConfigError')<{
field: string
message: string
}> {}
/**
* The request never produced an HTTP response.
*
* Covers DNS failure, connection reset, abort, and timeout.
*/
export class ZoNetworkError extends TaggedError('ZoNetworkError')<{
url: string
retryable: boolean
cause: unknown
message: string
}> {}
/**
* Zo answered with a non-2xx status.
*
* `body` holds the response text, trimmed to 2000 characters.
*/
export class ZoApiError extends TaggedError('ZoApiError')<{
status: number
url: string
body: string
message: string
}> {}
/**
* The response arrived but did not match the documented shape.
*/
export class ZoParseError extends TaggedError('ZoParseError')<{
url: string
body: string
message: string
}> {}
/**
* The Server-Sent Events stream broke after it opened.
*/
export class ZoStreamError extends TaggedError('ZoStreamError')<{
url: string
cause: unknown
message: string
}> {}
/**
* Every error a non-streaming request can return.
*/
export type ZoRequestError =
| ZoConfigError
| ZoNetworkError
| ZoApiError
| ZoParseError
/**
* Every error this package can produce.
*/
export type ZoError = ZoRequestError | ZoStreamError