Show standard error messages.

This commit is contained in:
Arik Fraimovich 2018-02-08 09:32:08 +02:00
parent d6eb8f436f
commit e69f8fa009
2 changed files with 11 additions and 6 deletions

View File

@ -8,9 +8,6 @@
</div>
<div class="error-state__details">
<h4>{{ $ctrl.handler.error.message }}</h4>
<p>It seems like the page youre looking for cannot be found.</p>
<!--<p>It seems like you dont have permission to see this page.</p>-->
<!--<p>It seems like we encountered an error. Try refresh this page or contact your administrator.</p>-->
</div>
</div>
</div>

View File

@ -1,10 +1,18 @@
export default class PromiseRejectionError extends Error {
constructor(rejection) {
let message;
switch (rejection.status) {
case 403: message = 'You have no permissions to view this page.'; break;
default: message = rejection.data.message; break;
if (rejection.status !== undefined) {
if (rejection.status === 404) {
message = "It seems like the page you're looking for cannot be found.";
} else if (rejection.status === 403 || rejection.status === 401) {
message = 'It seems like you dont have permission to see this page.';
}
}
if (message === undefined) {
message = 'It seems like we encountered an error. Try refreshing this page or contact your administrator.';
}
super(message);
this.rejection = rejection;
}