Class: Trane::ErrorDefinition

Inherits:
Data
  • Object
show all
Defined in:
lib/trane/error_registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, status_code:, description: nil) ⇒ ErrorDefinition

Returns a new instance of ErrorDefinition.



5
6
7
8
9
10
11
12
# File 'lib/trane/error_registry.rb', line 5

def initialize(key:, status_code:, description: nil)
  status_int = status_code.to_i
  unless Trane::Types::HTTP_STATUS_RANGE.cover?(status_int)
    raise ArgumentError,
          "ErrorDefinition #{key.inspect} status_code #{status_code.inspect} is not a valid HTTP status code"
  end
  super(key: key.to_s, status_code: status_int, description: description&.to_s)
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



4
5
6
# File 'lib/trane/error_registry.rb', line 4

def description
  @description
end

#keyObject (readonly)

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



4
5
6
# File 'lib/trane/error_registry.rb', line 4

def key
  @key
end

#status_codeObject (readonly)

Returns the value of attribute status_code

Returns:

  • (Object)

    the current value of status_code



4
5
6
# File 'lib/trane/error_registry.rb', line 4

def status_code
  @status_code
end