UNPKG

1.57 kBJavaScriptView Raw
1/**
2 * -------------------------------------------------------------------------------------------
3 * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4 * See License in the project root for license information.
5 * -------------------------------------------------------------------------------------------
6 */
7/**
8 * @module GraphError
9 */
10/**
11 * @class
12 * Class for GraphError
13 * @NOTE: This is NOT what is returned from the Graph
14 * GraphError is created from parsing JSON errors returned from the graph
15 * Some fields are renamed ie, "request-id" => requestId so you can use dot notation
16 */
17export class GraphError extends Error {
18 /**
19 * @public
20 * @constructor
21 * Creates an instance of GraphError
22 * @param {number} [statusCode = -1] - The status code of the error
23 * @param {string} [message] - The message of the error
24 * @param {Error} [baseError] - The base error
25 * @returns An instance of GraphError
26 */
27 constructor(statusCode = -1, message, baseError) {
28 super(message || (baseError && baseError.message));
29 // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
30 Object.setPrototypeOf(this, GraphError.prototype);
31 this.statusCode = statusCode;
32 this.code = null;
33 this.requestId = null;
34 this.date = new Date();
35 this.body = null;
36 this.stack = baseError ? baseError.stack : this.stack;
37 }
38}
39//# sourceMappingURL=GraphError.js.map
\No newline at end of file