mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 19:47:54 +00:00
Backport of UI: Handle error from ResponseWithStatusCode (#23116)
Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
79cd74d713
commit
ac08ecb7fb
@@ -119,10 +119,18 @@ export default RESTAdapter.extend({
|
|||||||
|
|
||||||
handleResponse(status, headers, payload, requestData) {
|
handleResponse(status, headers, payload, requestData) {
|
||||||
const returnVal = this._super(...arguments);
|
const returnVal = this._super(...arguments);
|
||||||
// ember data errors don't have the status code, so we add it here
|
|
||||||
if (returnVal instanceof AdapterError) {
|
if (returnVal instanceof AdapterError) {
|
||||||
|
// ember data errors don't have the status code, so we add it here
|
||||||
set(returnVal, 'httpStatus', status);
|
set(returnVal, 'httpStatus', status);
|
||||||
set(returnVal, 'path', requestData.url);
|
set(returnVal, 'path', requestData.url);
|
||||||
|
// Most of the time when the Vault API returns an error, the payload looks like:
|
||||||
|
// { errors: ['some error message']}
|
||||||
|
// But sometimes (eg RespondWithStatusCode) it looks like this:
|
||||||
|
// { data: { error: 'some error message' } }
|
||||||
|
if (payload?.data?.error && !payload.errors) {
|
||||||
|
// Normalize the errors from RespondWithStatusCode
|
||||||
|
set(returnVal, 'errors', [payload.data.error]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return returnVal;
|
return returnVal;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user