Commit 152d31ba authored by dev0tion's avatar dev0tion

Add basic error handling to API calls

parent f2894890
......@@ -104,10 +104,10 @@ export class LoginComponent implements OnInit {
}
},
error => {
let errorMessage = <any>error;
if (error.status >= 400) {
alert(errorMessage);
console.log(errorMessage);
if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) {
alert(error);
}
}
)
......@@ -125,12 +125,10 @@ export class LoginComponent implements OnInit {
}
},
error => {
let errorMessage = <any>error;
if (error.status === 403 && error.json().errors[0].message === "Wrong password, please try again.") {
alert("Wrong password, try again.");
if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) {
alert(errorMessage);
console.log(errorMessage);
alert(error);
}
}
)
......
......@@ -98,9 +98,10 @@ export class CreateComponent {
}
},
error => {
if (error.status >= 400) {
let errorMessage = error;
console.log(errorMessage);
if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) {
alert(error);
}
}
)
......
......@@ -112,9 +112,10 @@ export class RecoverComponent implements OnInit {
}
},
error => {
if (error.status >= 400) {
this.errorMessage = error;
console.log(this.errorMessage);
if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) {
alert(error);
}
}
);
......
......@@ -57,9 +57,10 @@ export class DashboardComponent {
}
},
error => {
if (error.status >= 400) {
let errorMessage = <any>error;
console.log(errorMessage);
if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) {
alert(error);
}
}
)
......@@ -78,9 +79,10 @@ export class DashboardComponent {
}
},
error => {
if (error.status >= 400) {
let errorMessage = <any>error;
console.log(errorMessage);
if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) {
alert(error);
}
}
)
......
......@@ -41,9 +41,10 @@ export class HistoryComponent {
}
},
error => {
if (error.status >= 400) {
this.errorMessage = <any>error;
console.log(this.errorMessage);
if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) {
alert(error);
}
}
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment