wip: Construct API
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import { APIErrorEnum } from "./APIErrorEnum";
|
||||
|
||||
export class APICallerError extends Error {
|
||||
constructor(error) {
|
||||
super(error.message);
|
||||
this.errorName = error.name;
|
||||
this.errorMessage = error.message;
|
||||
this.errorCode = APIErrorEnum.Caller;
|
||||
this.name = "APICallerError";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export const APIErrorEnum = Object.freeze({
|
||||
Unknown: 0,
|
||||
Success: 1,
|
||||
Caller: 2,
|
||||
Server: 3
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import { APIErrorEnum } from "./APIErrorEnum";
|
||||
|
||||
export class APIServerError extends Error {
|
||||
constructor(error) {
|
||||
super(error.message);
|
||||
this.thrownError = error;
|
||||
this.errorCode = APIErrorEnum.Server;
|
||||
this.name = "APIServerError";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export class APIVersionMismatchError extends Error {
|
||||
constructor(serverApiVersion, callerApiVersion) {
|
||||
super(`API version numbers do not match (${callerApiVersion} != ${serverApiVersion}). Please use API version ${serverApiVersion}.`);
|
||||
this.name = 'APIVersionMismatchError';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user