ms-rest-js icon indicating copy to clipboard operation
ms-rest-js copied to clipboard

error handling in xhrHttpClient

Open xuke444 opened this issue 5 years ago • 1 comments

in the rejectOnTerminalEvent of xhrHttpClient, when throw error for "error" event, the xhr.response is not passed, instead it passes undefined. xhr.addEventListener("error", () => reject(new RestError(Failed to send request to ${request.url}, RestError.REQUEST_SEND_ERROR, undefined, request)));

can xhr.response be added to replace undefined above? So that we can know the details of error to handle it correctly.

xuke444 avatar Dec 06 '19 19:12 xuke444

the third parameter of RestError constructor is statusCode. We could pass xhr.response as the last parameter, after request. One concern is that the error response may contain sensitive information and we probably don't want to leak everything in the error?

jeremymeng avatar Jan 27 '21 21:01 jeremymeng