20 lines
504 B
TypeScript
20 lines
504 B
TypeScript
|
|
import type { ClarizenErrorBody } from "./types.js";
|
||
|
|
|
||
|
|
export class ClarizenApiError extends Error {
|
||
|
|
readonly errorCode: string;
|
||
|
|
readonly referenceId?: string;
|
||
|
|
readonly status: number;
|
||
|
|
|
||
|
|
constructor(status: number, body: ClarizenErrorBody) {
|
||
|
|
super(body.message);
|
||
|
|
this.name = "ClarizenApiError";
|
||
|
|
this.status = status;
|
||
|
|
this.errorCode = body.errorCode;
|
||
|
|
this.referenceId = body.referenceId;
|
||
|
|
}
|
||
|
|
|
||
|
|
isSessionTimeout(): boolean {
|
||
|
|
return this.errorCode === "SessionTimeout";
|
||
|
|
}
|
||
|
|
}
|