Exception: Bosh::Director::DirectorError
- Defined in:
- lib/bosh/director/errors.rb
Overview
DirectorError is a generic exception for most of the errors originated in BOSH Director.
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#response_code ⇒ Object
readonly
Returns the value of attribute response_code.
Class Method Summary collapse
-
.create_from_exception(exception) ⇒ DirectorError
Wraps an exception to DirectorError, so it can be assigned a generic error code and properly logged.
-
.define_error(error_code, response_code) ⇒ Class
Creates a new subclass of DirectorError with given name, error code and response code.
Instance Method Summary collapse
-
#initialize(message = nil) ⇒ DirectorError
constructor
A new instance of DirectorError.
Constructor Details
#initialize(message = nil) ⇒ DirectorError
Returns a new instance of DirectorError.
43 44 45 46 47 48 |
# File 'lib/bosh/director/errors.rb', line 43 def initialize( = nil) super @response_code = 500 @error_code = 100 @format = "Director error: %s" end |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
41 42 43 |
# File 'lib/bosh/director/errors.rb', line 41 def error_code @error_code end |
#response_code ⇒ Object (readonly)
Returns the value of attribute response_code.
40 41 42 |
# File 'lib/bosh/director/errors.rb', line 40 def response_code @response_code end |
Class Method Details
.create_from_exception(exception) ⇒ DirectorError
Wraps an exception to DirectorError, so it can be assigned a generic error code and properly logged.
16 17 18 19 20 21 22 |
# File 'lib/bosh/director/errors.rb', line 16 def self.create_from_exception(exception) if exception.kind_of?(DirectorError) exception else DirectorError.new(exception.) end end |
.define_error(error_code, response_code) ⇒ Class
Creates a new subclass of DirectorError with given name, error code and response code
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bosh/director/errors.rb', line 29 def self.define_error(error_code, response_code) Class.new(DirectorError) do define_method(:initialize) do |*args| = args[0] super() @error_code = error_code @response_code = response_code end end end |