Class: Jsapi::Controller::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/jsapi/controller/error.rb

Overview

Used by Methods#api_operation! to produce an error response.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#statusObject (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_sObject

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