1
0
mirror of https://github.com/flarum/core.git synced 2025-08-07 08:56:38 +02:00

Have a go at some error handling

Still not happy with how this is all fitting together. But good enough
for now
This commit is contained in:
Toby Zerner
2015-02-26 12:48:23 +10:30
parent c2c731f6a6
commit 57f4dc6091
8 changed files with 118 additions and 50 deletions

View File

@@ -25,12 +25,17 @@ export default JsonApiAdapter.extend({
// If it's a server error, show an alert message. The alerts controller
// has been injected into this adapter.
if (errors instanceof JsonApiAdapter.ServerError) {
var message = AlertMessage.create({
var message;
if (errors.status === 401) {
message = 'You don\'t have permission to do this.';
} else {
message = errors.message;
}
var alert = AlertMessage.create({
type: 'warning',
message: 'Something went wrong: '+errors.message.errors[0].code
message: message
});
this.get('alerts').send('alert', message);
return;
this.get('alerts').send('alert', alert);
}
return errors;