From 3f35a9ab6485fcf68c3ce0670ac8d0d872e47de4 Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 5 Apr 2017 00:32:41 -0500 Subject: [PATCH] Handle failure gracefully for unconfigured services. --- app/controllers/application_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ddbd755c1..4a04fa270 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -84,6 +84,13 @@ class ApplicationController < ActionController::Base elsif exception.is_a?(::ActiveRecord::RecordNotFound) @error_message = "That record was not found" render :template => "static/error", :status => 404 + elsif exception.is_a?(NotImplementedError) + flash[:notice] = "This feature isn't available: #{@exception.message}" + respond_to do |fmt| + fmt.html { redirect_to :back } + fmt.json { render template: "static/error", status: 501 } + fmt.xml { render template: "static/error", status: 501 } + end else render :template => "static/error", :status => 500 end