summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-09-03 10:38:39 -0700
committerjessib <jessib@riseup.net>2013-09-03 10:38:39 -0700
commitf97777ed0252abe94f8d94cb4565fb5a6c35ab23 (patch)
treec943e772cf403387822364bbcbe23f59bdb17504 /app/controllers/application_controller.rb
parenta3e7cf7b667ec2080d8930b3c2659978a4c95a9b (diff)
parent1bcc76b4f50a181a1b3c137c79b627257187ac3c (diff)
Merge pull request #76 from azul/feature/3600-visual-feedback-on-failed-signup
Ensure json requests get json error response on failure
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 9734a33..b808e1c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -7,6 +7,19 @@ class ApplicationController < ActionController::Base
protected
+
+ rescue_from StandardError do |e|
+ respond_to do |format|
+ format.json { render_json_error }
+ format.all { raise e } # reraise the exception so the normal thing happens.
+ end
+ end
+
+ def render_json_error
+ render status: 500,
+ json: {error: "The server failed to process your request. We'll look into it."}
+ end
+
#
# Allows us to pass through bold text to flash messages. See format_flash() for where this is reversed.
#