UNPKG

@forestadmin/datasource-toolkit

Version:
61 lines 2.62 kB
export declare class BusinessError extends Error { readonly isBusinessError = true; baseBusinessErrorName: string; readonly data: Record<string, unknown> | undefined; constructor(message?: string, data?: Record<string, unknown>, name?: string); /** * We cannot rely on `instanceof` because there can be some mismatch between * packages versions as dependencies of different packages. * So this function is a workaround to check if an error is of a specific type. */ static isOfType(error: Error, ErrorConstructor: new (...args: never[]) => Error): boolean; } export declare class ValidationError extends BusinessError { constructor(message?: string, data?: Record<string, unknown>, name?: string); } export declare class BadRequestError extends BusinessError { constructor(message?: string, data?: Record<string, unknown>, name?: string); } export declare class UnprocessableError extends BusinessError { constructor(message?: string, data?: Record<string, unknown>, name?: string); } export declare class ForbiddenError extends BusinessError { constructor(message?: string, data?: Record<string, unknown>, name?: string); } export declare class NotFoundError extends BusinessError { constructor(message?: string, data?: Record<string, unknown>, name?: string); } export declare class IntrospectionFormatError extends BusinessError { constructor(sourcePackageName: '@forestadmin/datasource-sql' | '@forestadmin/datasource-mongo'); /** @deprecated use name instead */ get type(): string; } export declare class MissingSchemaElementError extends ValidationError { } export declare class MissingCollectionError extends MissingSchemaElementError { } type MissingFieldErrorOptions = { fieldName: string; availableFields: string[]; collectionName?: string; }; export declare class RelationFieldAccessDeniedError extends ValidationError { constructor(options: Pick<MissingFieldErrorOptions, 'fieldName' | 'collectionName'>); } export declare class MissingFieldError extends MissingSchemaElementError { constructor(options: MissingFieldErrorOptions); } export declare class MissingColumnError extends MissingSchemaElementError { constructor(options: MissingFieldErrorOptions); } export declare class MissingRelationError extends MissingSchemaElementError { constructor(options: MissingFieldErrorOptions); } export declare class AlreadyDefinedFieldError extends ValidationError { constructor(options: { fieldName: string; collectionName?: string; }); } export {}; //# sourceMappingURL=errors.d.ts.map