diff --git a/app/assets/javascripts/discourse/controllers/edit-category.js.es6 b/app/assets/javascripts/discourse/controllers/edit-category.js.es6 index bfda086b643..0810068b477 100644 --- a/app/assets/javascripts/discourse/controllers/edit-category.js.es6 +++ b/app/assets/javascripts/discourse/controllers/edit-category.js.es6 @@ -1,5 +1,6 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; import DiscourseURL from 'discourse/lib/url'; +import { extractError } from 'discourse/lib/ajax-error'; // Modal for editing / creating a category export default Ember.Controller.extend(ModalFunctionality, { @@ -73,11 +74,7 @@ export default Ember.Controller.extend(ModalFunctionality, { model.setProperties({slug: result.category.slug, id: result.category.id }); DiscourseURL.redirectTo("/c/" + Discourse.Category.slugFor(model)); }).catch(function(error) { - if (error && error.responseText) { - self.flash($.parseJSON(error.responseText).errors[0], 'error'); - } else { - self.flash(I18n.t('generic_error'), 'error'); - } + self.flash(extractError(error), 'error'); self.set('saving', false); }); }, @@ -94,13 +91,7 @@ export default Ember.Controller.extend(ModalFunctionality, { self.send('closeModal'); DiscourseURL.redirectTo("/categories"); }, function(error){ - - if (error && error.responseText) { - self.flash($.parseJSON(error.responseText).errors[0]); - } else { - self.flash(I18n.t('generic_error')); - } - + self.flash(extractError(error), 'error'); self.send('reopenModal'); self.displayErrors([I18n.t("category.delete_error")]); self.set('deleting', false);