Skip to content
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/microsoft-graph-client",
"version": "2.1.0-Preview.2",
"version": "2.2.0-Preview.1",
"description": "Microsoft Graph Client Library",
"license": "MIT",
"main": "lib/src/index.js",
Expand Down
7 changes: 7 additions & 0 deletions spec/core/GraphErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { assert } from "chai";

import { GraphError } from "../../src";
import { GraphErrorHandler } from "../../src/GraphErrorHandler";

describe("GraphErrorHandler.ts", () => {
Expand Down Expand Up @@ -41,6 +42,7 @@ describe("GraphErrorHandler.ts", () => {

it("Should construct error for error response without innerError property", () => {
const gError = GraphErrorHandler["constructErrorFromResponse"](error, statusCode);
assert.isTrue(gError instanceof GraphError);
assert.equal(gError.statusCode, statusCode);
assert.equal(gError.requestId, null);
});
Expand All @@ -50,6 +52,7 @@ describe("GraphErrorHandler.ts", () => {
"request-id": "some random id",
};
const gError = GraphErrorHandler["constructErrorFromResponse"](error, statusCode);
assert.isTrue(gError instanceof GraphError);
assert.equal(gError.statusCode, statusCode);
assert.equal(gError.requestId, "some random id");
});
Expand All @@ -62,6 +65,7 @@ describe("GraphErrorHandler.ts", () => {
date,
};
const gError = GraphErrorHandler["constructErrorFromResponse"](error, statusCode);
assert.isTrue(gError instanceof GraphError);
assert.equal(gError.statusCode, statusCode);
assert.equal(gError.requestId, "some random id");
assert.equal(gError.date.toUTCString(), date.toUTCString());
Expand All @@ -81,6 +85,7 @@ describe("GraphErrorHandler.ts", () => {
},
};
const gError = await GraphErrorHandler.getError(errorResponse);
assert.isTrue(gError instanceof GraphError);
assert.equal(gError.requestId, "some random id");
assert.equal(gError.code, "500");
assert.equal(gError.message, "Internal Server Error");
Expand All @@ -90,13 +95,15 @@ describe("GraphErrorHandler.ts", () => {
const error = new Error("Some Error");
error.name = "InvalidError";
const gError = await GraphErrorHandler.getError(error);
assert.isTrue(gError instanceof GraphError);
assert.equal(gError.requestId, null);
assert.equal(gError.message, "Some Error");
assert.equal(gError.code, "InvalidError");
});

it("Should construct some default error", async () => {
const gError = await GraphErrorHandler.getError();
assert.isTrue(gError instanceof GraphError);
assert.equal(gError.message, "");
assert.equal(gError.statusCode, -1);
assert.equal(gError.code, null);
Expand Down
2 changes: 2 additions & 0 deletions src/GraphError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export class GraphError extends Error {
*/
public constructor(statusCode: number = -1, message?: string, baseError?: Error) {
super(message || (baseError && baseError.message));
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, GraphError.prototype);
this.statusCode = statusCode;
this.code = null;
this.requestId = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
* @module Version
*/

export const PACKAGE_VERSION = "2.1.0-Preview.2";
export const PACKAGE_VERSION = "2.2.0-Preview.1";