9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/stockpot/helper/errors.rb', line 9
def rescue_error(error)
logger = Logger.new($stderr)
logger.warn(error)
case error
when NameError
return_error(error.message, :bad_request, error.backtrace.first(5))
when PG::Error
return_error("Postgres error: #{error.message}", :internal_server_error, error.backtrace.first(5))
when ActiveRecord::RecordInvalid, ActiveRecord::Validations, ActiveRecord::RecordNotDestroyed
return_error(%q(In "#{error.record.class}" class: "#{error.message}"), :expectation_failed, error.backtrace.first(5))
else
return_error(error.message, :internal_server_error, error.backtrace.first(5))
end
end
|