Class: DeltaCloud::HTTPError::ExceptionHandler
- Inherits:
-
Object
- Object
- DeltaCloud::HTTPError::ExceptionHandler
- Defined in:
- lib/errors.rb
Instance Attribute Summary collapse
-
#http_status_code ⇒ Object
readonly
Returns the value of attribute http_status_code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#trace ⇒ Object
readonly
Returns the value of attribute trace.
Instance Method Summary collapse
-
#initialize(status_code, message = nil, opts = {}, backtrace = nil, &block) ⇒ ExceptionHandler
constructor
A new instance of ExceptionHandler.
- #on(code, exception_class) ⇒ Object
Constructor Details
#initialize(status_code, message = nil, opts = {}, backtrace = nil, &block) ⇒ ExceptionHandler
Returns a new instance of ExceptionHandler.
67 68 69 70 71 72 73 |
# File 'lib/errors.rb', line 67 def initialize(status_code, =nil, opts={}, backtrace=nil, &block) @http_status_code = status_code.to_i @trace = backtrace = || [status_code] || 'No error message received' = opts instance_eval(&block) if block_given? end |
Instance Attribute Details
#http_status_code ⇒ Object (readonly)
Returns the value of attribute http_status_code.
65 66 67 |
# File 'lib/errors.rb', line 65 def http_status_code @http_status_code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
65 66 67 |
# File 'lib/errors.rb', line 65 def end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
65 66 67 |
# File 'lib/errors.rb', line 65 def trace @trace end |
Instance Method Details
#on(code, exception_class) ⇒ Object
75 76 77 78 79 |
# File 'lib/errors.rb', line 75 def on(code, exception_class) if code == @http_status_code raise exception_class.new(code, , , @trace) end end |