Class: Trane::ErrorDefinition
- Inherits:
-
Data
- Object
- Data
- Trane::ErrorDefinition
- Defined in:
- lib/trane/error_registry.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(key:, status_code:, description: nil) ⇒ ErrorDefinition
constructor
A new instance of ErrorDefinition.
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
#description ⇒ Object (readonly)
Returns the value of attribute description
4 5 6 |
# File 'lib/trane/error_registry.rb', line 4 def description @description end |
#key ⇒ Object (readonly)
Returns the value of attribute key
4 5 6 |
# File 'lib/trane/error_registry.rb', line 4 def key @key end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code
4 5 6 |
# File 'lib/trane/error_registry.rb', line 4 def status_code @status_code end |