class Praxis::Responses::InternalServerError
A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
Attributes
Public Class Methods
Source
# File lib/praxis/responses/internal_server_error.rb, line 10 def initialize(error: nil, **opts) super(**opts) @headers['Content-Type'] = 'application/json' # TODO: might want an error mediatype @error = error end
Calls superclass method
Praxis::Response::new
Public Instance Methods
Source
# File lib/praxis/responses/internal_server_error.rb, line 16 def format!(exception = @error) return unless @error if Application.instance.config.praxis.show_exceptions == true msg = { name: exception.class.name, message: exception.message, backtrace: exception.backtrace } msg[:cause] = format!(exception.cause) if exception.cause else msg = { name: 'InternalServerError', message: 'Something bad happened.' } end @body = msg end