Fix LRO RestErrors parsing (#104)
* Fix LRO RestErrors parsing * Add JSON parsing error handling
This commit is contained in:
Родитель
cee5adbef6
Коммит
56432e04b9
|
@ -397,7 +397,15 @@ class LocationLROPollStrategy extends LROPollStrategy {
|
|||
lroPollState.resource = getResponseBody(result);
|
||||
} else if (400 <= statusCode && statusCode <= 499) {
|
||||
const resultBody: string = result.bodyAsText!;
|
||||
throw new RestError(resultBody, undefined, statusCode, stripRequest(result.request), result, resultBody);
|
||||
let errorMessage: string = resultBody;
|
||||
try {
|
||||
const resultObject = JSON.parse(resultBody);
|
||||
errorMessage = resultObject.message;
|
||||
} catch (parseError) {
|
||||
// Ignore the exception, use resultBody as the error message
|
||||
}
|
||||
|
||||
throw new RestError(errorMessage, undefined, statusCode, stripRequest(result.request), result, resultBody);
|
||||
} else {
|
||||
throw new Error(`The response with status code ${statusCode} from polling for long running operation url "${lroPollState.locationHeaderValue}" is not valid.`);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"email": "azsdkteam@microsoft.com",
|
||||
"url": "https://github.com/Azure/ms-rest-azure-js"
|
||||
},
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"description": "Isomorphic Azure client runtime for Typescript/node.js/browser javascript client libraries generated using AutoRest",
|
||||
"tags": [
|
||||
"isomorphic",
|
||||
|
|
Загрузка…
Ссылка в новой задаче