5dc43cbc8b
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.
25 lines
583 B
TypeScript
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;
|
|
};
|