module Ballast::Concerns::ErrorsHandling
A concern to handle errors. It requires the Ajax concern.
Public Instance Methods
handle_error(exception, layout: "error", title: "Error - Application", format: nil)
click to toggle source
Handles an error in the application.
@param exception [Hash|Exception] The exception to handle. @param layout [String] The layout to use to render the error. The `@error` variable will be exposed. @param title [String] The title to set in case of custom errors. @param format [String|Symbol|NilClass] The format of the response.
# File lib/ballast/concerns/errors_handling.rb, line 18 def handle_error(exception, layout: "error", title: "Error - Application", format: nil) @error = if exception.is_a?(Lazier::Exceptions::Debug) {status: 503, title: "Debug", error: exception.message, exception: exception} elsif exception.is_a?(::Hash) exception.reverse_merge({title: title}) else {status: 500, title: "Error - #{exception.class}", error: exception.message, exception: exception} end send_or_render_error(layout, format) end