Exception: RequestError
- Defined in:
- lib/frecon/request_error.rb
Instance Attribute Summary collapse
-
#return_value ⇒ Object
readonly
Returns the value of attribute return_value.
Instance Method Summary collapse
-
#initialize(code, message = nil, context = nil) ⇒ RequestError
constructor
A new instance of RequestError.
Constructor Details
#initialize(code, message = nil, context = nil) ⇒ RequestError
Returns a new instance of RequestError.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/frecon/request_error.rb', line 15 def initialize(code, = nil, context = nil) @code = code = @context = context # When @message is a String or an Array, # the return_value is set to a Sinatra-compliant # Array with @code being the first element and the # response body being the stringification of the # JSON stringification of @context and @message. # # If @message is a String, it is first put into an # array. # # If @message is neither a String nor an Array, # @return_value becomes simply @code. @return_value = case when String [@code, JSON.generate({ context: @context, errors: [ ] })] when Array [@code, JSON.generate({ context: @context, errors: })] else @code end end |
Instance Attribute Details
#return_value ⇒ Object (readonly)
Returns the value of attribute return_value.
13 14 15 |
# File 'lib/frecon/request_error.rb', line 13 def return_value @return_value end |