Class: Jsapi::Controller::Error
- Inherits:
-
Object
- Object
- Jsapi::Controller::Error
- Defined in:
- lib/jsapi/controller/error.rb
Overview
Used by Methods#api_operation! to produce an error response.
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
The HTTP status code of the error response to be produced.
Instance Method Summary collapse
-
#initialize(exception, status: nil) ⇒ Error
constructor
Creates a new instance to produce an error response with the given HTTP status code.
-
#to_s ⇒ Object
Returns the string representation of the exception encountered to render this string when the response type is
string
, for example:.
Constructor Details
#initialize(exception, status: nil) ⇒ Error
Creates a new instance to produce an error response with the given HTTP status code.
13 14 15 16 |
# File 'lib/jsapi/controller/error.rb', line 13 def initialize(exception, status: nil) @exception = exception @status = status end |
Instance Attribute Details
#status ⇒ Object (readonly)
The HTTP status code of the error response to be produced.
10 11 12 |
# File 'lib/jsapi/controller/error.rb', line 10 def status @status end |
Instance Method Details
#to_s ⇒ Object
Returns the string representation of the exception encountered to render this string when the response type is string
, for example:
response 500, type: 'string'
22 23 24 |
# File 'lib/jsapi/controller/error.rb', line 22 def to_s @exception.to_s end |