Class: Praxis::Responses::InternalServerError
- Inherits:
-
Praxis::Response
- Object
- Praxis::Response
- Praxis::Responses::InternalServerError
- Defined in:
- lib/praxis/responses/internal_server_error.rb
Overview
A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
Attributes inherited from Praxis::Response
#body, #headers, #name, #parts, #request, #status
Instance Method Summary collapse
- #format!(exception = @error) ⇒ Object
-
#initialize(error: nil, **opts) ⇒ InternalServerError
constructor
A new instance of InternalServerError.
Methods inherited from Praxis::Response
#add_part, #content_type, #content_type=, #encode!, #finish, #handle, inherited, #response_name, #validate
Constructor Details
#initialize(error: nil, **opts) ⇒ InternalServerError
Returns a new instance of InternalServerError.
10 11 12 13 14 |
# 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 |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
8 9 10 |
# File 'lib/praxis/responses/internal_server_error.rb', line 8 def error @error end |
Instance Method Details
#format!(exception = @error) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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., backtrace: exception.backtrace } msg[:cause] = format!(exception.cause) if exception.cause else msg = { name: 'InternalServerError', message: 'Something bad happened.' } end @body = msg end |