ms-rest-js
ms-rest-js copied to clipboard
error handling in xhrHttpClient
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.
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?