mirror of
https://github.com/flarum/core.git
synced 2025-07-20 08:11:27 +02:00
Improve error handling somewhat
- Fix composer crashing/not showing alert on error - Make a general ValidationException which takes an array of field ⇒ messages to be outputted nicely by the API
This commit is contained in:
@@ -108,7 +108,11 @@ export default class DiscussionComposer extends ComposerBody {
|
||||
app.cache.discussionList.addDiscussion(discussion);
|
||||
m.route(app.route.discussion(discussion));
|
||||
},
|
||||
() => this.loading = false
|
||||
response => {
|
||||
this.loading = false;
|
||||
m.redraw();
|
||||
app.alertErrors(response.errors);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -92,10 +92,10 @@ export default class ReplyComposer extends ComposerBody {
|
||||
|
||||
app.composer.hide();
|
||||
},
|
||||
errors => {
|
||||
response => {
|
||||
this.loading = false;
|
||||
m.redraw();
|
||||
app.alertErrors(errors);
|
||||
app.alertErrors(response.errors);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -215,8 +215,8 @@ export default class App {
|
||||
alertErrors(errors) {
|
||||
errors.forEach(error => {
|
||||
this.alerts.show(new Alert({
|
||||
type: 'warning',
|
||||
message: error.detail
|
||||
type: 'error',
|
||||
children: error.detail
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user