Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/CraftgateError.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
type ProviderError = {
errorCode?: string;
errorMessage?: string;
};

type ErrorResponse = {
errorCode: string;
errorDescription: string;
providerError?: ProviderError;
};

export default class CraftgateError extends Error {
private _errorCode: string;
private _errorDescription: string;
private _providerError?: ProviderError;
private _errorData: any;

constructor({errorCode, errorDescription, ...rest}: ErrorResponse) {
constructor({errorCode, errorDescription, providerError, ...rest}: ErrorResponse) {
super(errorDescription);

this._errorCode = errorCode;
this._errorDescription = errorDescription;
this._providerError = providerError;
this._errorData = rest;

Object.setPrototypeOf(this, CraftgateError.prototype);
Expand All @@ -26,6 +34,10 @@ export default class CraftgateError extends Error {
return this._errorDescription;
}

getProviderError(): ProviderError | undefined {
return this._providerError;
}

getErrorData(): any {
return this._errorData;
}
Expand Down