type GscErrorKind = 'auth-expired' | 'rate-limited' | 'not-found' | 'validation' | 'storage' | 'transport'; type GscError = { kind: 'auth-expired'; message: string; cause: unknown; } | { kind: 'rate-limited'; message: string; retryAfter?: number; cause: unknown; } | { kind: 'not-found'; message: string; cause: unknown; } | { kind: 'validation'; message: string; cause: unknown; } | { kind: 'storage'; message: string; cause: unknown; } | { kind: 'transport'; message: string; status?: number; cause: unknown; }; /** * Classify an unknown error into a `GscError` discriminated union. * Transport is the catch-all — anything without a recognizable status ends up there. */ declare function classifyError(cause: unknown): GscError; /** * Re-raises a `GscError` value as an `Error`, preserving its `cause` for * stack-walking and stashing the original union under `.gscError`. Pairs with * `unwrapResult` from `gscdump/result` so a `fooResult(): Result` * core can be wrapped by a throwing `foo()` without losing the typed error. */ declare function gscErrorToException(error: GscError): Error; interface GscApiErrorInfo { code: number; message: string; reason?: string; status?: string; } declare function parseGoogleError(text: string, httpStatus?: number): GscApiErrorInfo; declare class GscApiError extends Error { info: GscApiErrorInfo; constructor(message: string, info: GscApiErrorInfo); } /** * Returns a handler that re-throws `unknown` as a `GscApiError` prefixed with * `prefix`. Recognises `ofetch` `FetchError` (parses `err.data` as Google JSON * via `parseGoogleError`); passes through existing `GscApiError`; re-throws * anything else as-is. */ declare function rethrowAsGscApiError(prefix: string): (err: unknown) => never; /** * String-matches an error against the signals Google returns when a token * has lost access to a property (revoked, downgraded, or never had it). * Cheaper than a full {@link classifyError} call when the caller only * needs the permission verdict. */ declare function isPermissionDeniedError(err: unknown): boolean; export { GscApiError, GscApiErrorInfo, GscError, GscErrorKind, classifyError, gscErrorToException, isPermissionDeniedError, parseGoogleError, rethrowAsGscApiError };