make sure we correctly extract error message fields.
This commit is contained in:
parent
947f0251dd
commit
8ee98845cc
|
@ -253,7 +253,7 @@ export class MedicalSourcesConnectedComponent implements OnInit {
|
||||||
}
|
}
|
||||||
errData.error_data = {
|
errData.error_data = {
|
||||||
summary: toastNotification.message,
|
summary: toastNotification.message,
|
||||||
error: JSON.stringify(err),
|
error: JSON.stringify(err, this.replaceErrors),
|
||||||
stack: err.stack
|
stack: err.stack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,17 +262,31 @@ export class MedicalSourcesConnectedComponent implements OnInit {
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
//https://stackoverflow.com/a/18391400/1157633
|
||||||
extractErrorFromResponse(errResp: any): string {
|
extractErrorFromResponse(errResp: any): string {
|
||||||
let errMsg = ""
|
let errMsg = ""
|
||||||
if(errResp.name == "HttpErrorResponse" && errResp.error && errResp.error?.error){
|
if(errResp.name == "HttpErrorResponse" && errResp.error && errResp.error?.error){
|
||||||
errMsg = errResp.error.error
|
errMsg = errResp.error.error
|
||||||
} else {
|
} else {
|
||||||
errMsg = JSON.stringify(errResp)
|
errMsg = JSON.stringify(errResp, this.replaceErrors)
|
||||||
}
|
}
|
||||||
return errMsg
|
return errMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//stringify error objects
|
||||||
|
replaceErrors(key, value) {
|
||||||
|
if (value instanceof Error) {
|
||||||
|
var error = {};
|
||||||
|
|
||||||
|
Object.getOwnPropertyNames(value).forEach(function (propName) {
|
||||||
|
error[propName] = value[propName];
|
||||||
|
});
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/smart-on-fhir/client-js/blob/8f64b770dbcd0abd30646e239cd446dfa4d831f6/src/lib.ts#L311
|
* https://github.com/smart-on-fhir/client-js/blob/8f64b770dbcd0abd30646e239cd446dfa4d831f6/src/lib.ts#L311
|
||||||
|
|
Loading…
Reference in New Issue