Fix to error handling mechanism: fail only on promise rejections

This commit is contained in:
Levko Kravets
2018-01-02 14:57:44 +02:00
parent bb36ec8664
commit dd0ffe3d2c

View File

@@ -10,15 +10,17 @@ export class ErrorHandler {
}
process(error) {
this.reset();
if (!(error instanceof Error)) {
if (error.status && error.data) {
// $q rejection
switch (error.status) {
case 403: error = new Error(''); break;
case 403: error = new Error('You have no permissions to view this page.'); break;
default: error = new Error(error.data.message); break;
}
}
this.error = error;
}
this.error = error;
if (this.logToConsole) {
// eslint-disable-next-line no-console
console.error(error);