From 5156ab1f72a1c2796c2555dd80569730a7b3e5a5 Mon Sep 17 00:00:00 2001 From: Kane York Date: Wed, 15 Jul 2015 12:51:33 -0700 Subject: [PATCH] Use HTTP status 422 for failures --- .../discourse/controllers/admin-plugins-explorer.js.es6 | 8 ++++++-- plugin.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 index 4da50b7..63878ac 100644 --- a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 @@ -182,9 +182,13 @@ export default Ember.ArrayController.extend({ } self.set('showResults', true); - }).catch(function(result) { + }).catch(function(err) { self.set('showResults', false); - self.set('results', result); + if (err.jqXHR && err.jqXHR.status === 422 && err.jqXHR.responseJSON) { + self.set('results', err.jqXHR.responseJSON); + } else { + popupAjaxError(err); + } }).finally(function() { self.set('loading', false); }); diff --git a/plugin.rb b/plugin.rb index 5bb6c22..d01cf33 100644 --- a/plugin.rb +++ b/plugin.rb @@ -720,7 +720,7 @@ SQL render json: { success: false, errors: [err_msg] - } + }, status: 422 else pg_result = result[:pg_result] cols = pg_result.fields