UNPKG

@proofkit/fmodata

Version:
74 lines (73 loc) 3.42 kB
import { StandardSchemaV1 } from '@standard-schema/spec'; /** * Base class for all fmodata errors */ export declare abstract class FMODataError extends Error { abstract readonly kind: string; readonly timestamp: Date; constructor(message: string, options?: ErrorOptions); } export declare class HTTPError extends FMODataError { readonly kind: "HTTPError"; readonly url: string; readonly status: number; readonly statusText: string; readonly response?: any; constructor(url: string, status: number, statusText: string, response?: any); is4xx(): boolean; is5xx(): boolean; isNotFound(): boolean; isUnauthorized(): boolean; isForbidden(): boolean; } export declare class ODataError extends FMODataError { readonly kind: "ODataError"; readonly url: string; readonly code?: string; readonly details?: any; constructor(url: string, message: string, code?: string, details?: any); } export declare class SchemaLockedError extends FMODataError { readonly kind: "SchemaLockedError"; readonly url: string; readonly code: string; readonly details?: any; constructor(url: string, message: string, details?: any); } export declare class ValidationError extends FMODataError { readonly kind: "ValidationError"; readonly field?: string; readonly issues: readonly StandardSchemaV1.Issue[]; readonly value?: unknown; constructor(message: string, issues: readonly StandardSchemaV1.Issue[], options?: { field?: string; value?: unknown; cause?: Error["cause"]; }); } export declare class ResponseStructureError extends FMODataError { readonly kind: "ResponseStructureError"; readonly expected: string; readonly received: any; constructor(expected: string, received: any); } export declare class RecordCountMismatchError extends FMODataError { readonly kind: "RecordCountMismatchError"; readonly expected: number | "one" | "at-most-one"; readonly received: number; constructor(expected: number | "one" | "at-most-one", received: number); } export declare class InvalidLocationHeaderError extends FMODataError { readonly kind: "InvalidLocationHeaderError"; readonly locationHeader?: string; constructor(message: string, locationHeader?: string); } export declare function isHTTPError(error: unknown): error is HTTPError; export declare function isValidationError(error: unknown): error is ValidationError; export declare function isODataError(error: unknown): error is ODataError; export declare function isSchemaLockedError(error: unknown): error is SchemaLockedError; export declare function isResponseStructureError(error: unknown): error is ResponseStructureError; export declare function isRecordCountMismatchError(error: unknown): error is RecordCountMismatchError; export declare function isFMODataError(error: unknown): error is FMODataError; export type { TimeoutError, AbortError, NetworkError, RetryLimitError, CircuitOpenError, } from '@fetchkit/ffetch'; export type FMODataErrorType = import('@fetchkit/ffetch').TimeoutError | import('@fetchkit/ffetch').AbortError | import('@fetchkit/ffetch').NetworkError | import('@fetchkit/ffetch').RetryLimitError | import('@fetchkit/ffetch').CircuitOpenError | HTTPError | ODataError | SchemaLockedError | ValidationError | ResponseStructureError | RecordCountMismatchError | InvalidLocationHeaderError;