2017-12-18 02:22:09 +00:00
|
|
|
export class ApiError {
|
|
|
|
|
|
|
|
public statusCode: number;
|
|
|
|
public jsonResponse: any;
|
|
|
|
|
|
|
|
constructor(statusCode: number, json: any) {
|
|
|
|
// Because typescript is just plain dumb
|
|
|
|
// https://stackoverflow.com/questions/31626231/custom-error-class-in-typescript
|
|
|
|
Error.apply(this, ["ApiError"]);
|
|
|
|
|
2017-12-24 09:02:57 +00:00
|
|
|
if (typeof(json) === "string") json = {message: json};
|
2017-12-18 02:22:09 +00:00
|
|
|
this.jsonResponse = json;
|
|
|
|
this.statusCode = statusCode;
|
|
|
|
}
|
|
|
|
}
|