Sometimes there are cases when an actual human needs to intervene during edge cases.
# app/lib/manual_intervention_error.rb
class ManualInterventionError < StandardError
def initialize(message = "An error occured that needs to be addressed manually")
super
end
end
class AppointmentsController < ApplicationController
rescue_from ManualInterventionError, with: :redirect_and_email_support
def create
if some_unique_condition
raise ManualInterventionError
end
end
private
def redirect_and_email_support
redirect_to root_path, alert: "There was an unexpected error. We have notified support."
ErrorMailer.generic_error.deliver_later
end
end