lib/http_error/response.rb in http-errors-0.1.0 vs lib/http_error/response.rb in http-errors-0.1.1
- old
+ new
@@ -3,18 +3,23 @@
extend ActiveSupport::Concern
included do
rescue_from HttpError::Error do |error|
Rails.logger.debug "Rescuing from #{error.class}. Status: #{error.status}. Message: #{error.message}"
+ render_error error
+ end
- hash = {
- error: error.message,
- }
+ private
- render \
- text: error.message,
- json: hash,
- status: error.status
- end
+ def render_error(error)
+ hash = {
+ error: error.message,
+ }
+
+ render \
+ text: error.message,
+ json: hash,
+ status: error.status
+ end
end
end
end