Files
docs/src/frontend/apps/impress/src/api/APIError.ts
T
Anthony LC 5dc43cbc8b (frontend) add ai blocknote feature
Add AI button to the editor toolbar.
We can use AI to generate content with our editor.
A list of predefined actions are available to use.
2024-10-16 22:58:52 +02:00

25 lines
583 B
TypeScript

interface IAPIError<T = unknown> {
status: number;
cause?: string[];
data?: T;
}
export class APIError<T = unknown> extends Error implements IAPIError<T> {
public status: IAPIError['status'];
public cause?: IAPIError['cause'];
public data?: IAPIError<T>['data'];
constructor(message: string, { status, cause, data }: IAPIError<T>) {
super(message);
this.name = 'APIError';
this.status = status;
this.cause = cause;
this.data = data;
}
}
export const isAPIError = (error: unknown): error is APIError => {
return error instanceof APIError;
};