Skip to content

Commit 5bd3aac

Browse files
Fixing #171
1 parent bce44e4 commit 5bd3aac

File tree

3 files changed

+2
-35
lines changed

3 files changed

+2
-35
lines changed

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)