Permalink
Browse files

fix(api): add workaround for Error init + clean up docs

  • Loading branch information...
RangerRick committed Aug 22, 2017
1 parent 72d6e32 commit 6f7a4aba2195d6298becddd3b09137e285e8b938
Showing with 29 additions and 7 deletions.
  1. +9 −1 src/api/OnmsError.ts
  2. +20 −6 src/rest/GrafanaError.ts
View
@@ -1,5 +1,5 @@
/**
* Represents an OpenNMS.js error. This will eventually have custom stuff to do... stuff.
* Represents an OpenNMS.js error.
* @module OnmsError
*/
export class OnmsError extends Error {
@@ -9,8 +9,14 @@ export class OnmsError extends Error {
*/
private statusCode: number;
/**
* The data (payload) associated with a response.
*/
private data: any;
/**
* The options provided as part of the request that resulted in this erro.
*/
private options: any;
/** The error code associated with this error. */
@@ -35,6 +41,8 @@ export class OnmsError extends Error {
} else {
this.stack = (new Error(message)).stack;
}
// workaround, see http://bit.ly/2vllGdD
Object.setPrototypeOf(this, OnmsError.prototype);
}
/**
View
@@ -1,12 +1,26 @@
import {OnmsError} from '../api/OnmsError';
/**
* A Grafana error object.
* @module GrafanaError
*/
export class GrafanaError extends OnmsError {
/**
* The request options (configuration).
* @hidden
*/
private config: any;
private config: any;
constructor(message: string, code?: number, options?: any, data?: any) {
super(message, code, options, data);
this.config = options;
}
/**
* Construct a new Grafana error.
* @param message The status message associated with the result.
* @param code The response code of the response.
* @param options The request options (configuration).
* @param data The payload of the response.
*/
constructor(message: string, code?: number, options?: any, data?: any) {
super(message, code, options, data);
this.config = options;
}
}

0 comments on commit 6f7a4ab

Please sign in to comment.