Skip to content

Commit 6acd070

Browse files
Merge branch 'dev' into Large_File_Upload_For_SharePoint
2 parents 80ba46b + ee8c432 commit 6acd070

File tree

4 files changed

+2
-58
lines changed

4 files changed

+2
-58
lines changed

spec/core/GraphErrorHandler.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,6 @@ describe("GraphErrorHandler.ts", () => {
3030
});
3131
});
3232

33-
describe("constructErrorFromRawResponse", async () => {
34-
it("Should parse error from raw response", async () => {
35-
const body = "unauthorized";
36-
const statusCode = 401;
37-
const errorResponse = new Response(body, {
38-
status: statusCode,
39-
});
40-
const gError = await GraphErrorHandler["constructErrorFromRawResponse"](errorResponse, statusCode);
41-
assert.equal(gError.statusCode, statusCode);
42-
assert.equal(gError.body, body);
43-
});
44-
45-
it("Should parse error without body", async () => {
46-
const statusCode = 401;
47-
const errorResponse = new Response(undefined, {
48-
status: statusCode,
49-
});
50-
const gError = await GraphErrorHandler["constructErrorFromRawResponse"](errorResponse, statusCode);
51-
assert.equal(gError.statusCode, statusCode);
52-
assert.isNull(gError.body);
53-
});
54-
});
55-
5633
describe("constructErrorFromResponse", () => {
5734
const statusCode = 400;
5835
const error: any = {

spec/core/GraphResponseHandler.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,5 @@ describe("GraphResponseHandler.ts", () => {
158158
const responseValue = await GraphResponseHandler.getResponse(response, ResponseType.TEXT);
159159
assert.isDefined(responseValue);
160160
});
161-
162-
it("Should parse from raw response for NOT OK response", async () => {
163-
try {
164-
const response = new Response("NOT OK", status500);
165-
const responseValue = await GraphResponseHandler.getResponse(response, ResponseType.TEXT);
166-
throw new Error("Something wrong with validating OK response");
167-
} catch (error) {
168-
assert.isDefined(error);
169-
assert.isTrue(error instanceof Response);
170-
assert.equal(error.status, 500);
171-
}
172-
});
173161
});
174162
});

src/GraphErrorHandler.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,6 @@ export class GraphErrorHandler {
3737
return gError;
3838
}
3939

40-
/**
41-
* @private
42-
* @static
43-
* @async
44-
* To construct error from the raw response
45-
* @param {Response} error - The error response
46-
* @param {number} statusCode - The status code of the response
47-
* @returns A promise that resolves to GraphError instance
48-
*/
49-
private static async constructErrorFromRawResponse(error: Response, statusCode: number): Promise<GraphError> {
50-
const gError = new GraphError(statusCode);
51-
try {
52-
gError.body = await error.text();
53-
} catch (error) {
54-
// tslint:disable-line: no-empty
55-
}
56-
return gError;
57-
}
58-
5940
/**
6041
* @private
6142
* @static
@@ -106,9 +87,7 @@ export class GraphErrorHandler {
10687
*/
10788
public static async getError(error: any = null, statusCode: number = -1, callback?: GraphRequestCallback): Promise<GraphError> {
10889
let gError: GraphError;
109-
if (error && (error.constructor.name === "Response" || error.constructor.name === "Body")) {
110-
gError = await GraphErrorHandler.constructErrorFromRawResponse(error, statusCode);
111-
} else if (error && error.error) {
90+
if (error && error.error) {
11291
gError = GraphErrorHandler.constructErrorFromResponse(error, statusCode);
11392
} else if (error && error.constructor.name === "Error") {
11493
gError = GraphErrorHandler.constructError(error, statusCode);

src/GraphResponseHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class GraphResponseHandler {
188188
}
189189
}
190190
} catch (error) {
191-
throw rawResponse.ok ? error : rawResponse;
191+
throw error;
192192
}
193193
}
194194
}

0 commit comments

Comments
 (0)