flip the lib type imports and move the xrpc error helpers off the old client
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,11 +4,29 @@ import {
|
||||
type Main,
|
||||
type Procedure,
|
||||
type Query,
|
||||
XrpcError,
|
||||
XrpcResponseError,
|
||||
} from '@atproto/lex'
|
||||
|
||||
import {com} from '#/lexicons'
|
||||
|
||||
/**
|
||||
* True for an XRPC error from a lex `Client` (`XrpcError` is the abstract base
|
||||
* of `XrpcResponseError`/`XrpcInvalidResponseError`/`XrpcInternalError`).
|
||||
*/
|
||||
export function isXrpcError(e: unknown): e is XrpcError {
|
||||
return e instanceof XrpcError
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP status, or undefined when `e` is not an XRPC error carrying a response.
|
||||
* Only `XrpcResponseError` (a genuine server response) has a status; the
|
||||
* internal/fetch lex errors do not.
|
||||
*/
|
||||
export function getErrorStatus(e: unknown): number | undefined {
|
||||
return e instanceof XrpcResponseError ? e.status : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Same nsid means `e` was thrown for this method schema, so `e` can be
|
||||
* treated as an `XrpcResponseError<M>` - which is what lets the SDK's
|
||||
|
||||
Reference in New Issue
Block a user