class Bosh::Director::DirectorError

DirectorError is a generic exception for most of the errors originated in BOSH Director.

Attributes

error_code[R]
response_code[R]

Public Class Methods

create_from_exception(exception) click to toggle source

Wraps an exception to DirectorError, so it can be assigned a generic error code and properly logged. @param [Exception] exception @return [DirectorError] Director error

# File lib/bosh/director/errors.rb, line 16
def self.create_from_exception(exception)
  if exception.kind_of?(DirectorError)
    exception
  else
    DirectorError.new(exception.message)
  end
end
define_error(error_code, response_code) click to toggle source

Creates a new subclass of DirectorError with given name, error code and response code @param [Fixnum] error_code Error code @param [Fixnum] response_code HTTP response code @return [Class]

Calls superclass method
# 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|
      message = args[0]
      super(message)
      @error_code = error_code
      @response_code = response_code
    end
  end
end
new(message = nil) click to toggle source
Calls superclass method
# File lib/bosh/director/errors.rb, line 43
def initialize(message = nil)
  super
  @response_code = 500
  @error_code = 100
  @format = "Director error: %s"
end