Exception: Underpass::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Underpass::Error
- Defined in:
- lib/underpass/errors.rb
Overview
Base error class for all Underpass errors.
Provides structured error data parsed from Overpass API responses.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ String?
readonly
The error code (e.g., “timeout”, “memory”, “syntax”).
-
#details ⇒ Hash
readonly
Additional error details (varies by error type).
-
#error_message ⇒ String?
readonly
The human-readable error message.
-
#http_status ⇒ Integer?
readonly
The HTTP status code from the API response.
Instance Method Summary collapse
-
#initialize(message = nil, code: nil, error_message: nil, details: {}, http_status: nil) ⇒ Error
constructor
Creates a new error with optional structured data.
-
#to_h ⇒ Hash
Returns a hash representation of the error.
-
#to_json ⇒ String
Returns a JSON representation of the error.
Constructor Details
#initialize(message = nil, code: nil, error_message: nil, details: {}, http_status: nil) ⇒ Error
Creates a new error with optional structured data.
40 41 42 43 44 45 46 |
# File 'lib/underpass/errors.rb', line 40 def initialize( = nil, code: nil, error_message: nil, details: {}, http_status: nil) @code = code @error_message = || @details = details || {} @http_status = http_status super(@error_message || ) end |
Instance Attribute Details
#code ⇒ String? (readonly)
Returns the error code (e.g., “timeout”, “memory”, “syntax”).
22 23 24 |
# File 'lib/underpass/errors.rb', line 22 def code @code end |
#details ⇒ Hash (readonly)
Returns additional error details (varies by error type).
28 29 30 |
# File 'lib/underpass/errors.rb', line 28 def details @details end |
#error_message ⇒ String? (readonly)
Returns the human-readable error message.
25 26 27 |
# File 'lib/underpass/errors.rb', line 25 def @error_message end |
#http_status ⇒ Integer? (readonly)
Returns the HTTP status code from the API response.
31 32 33 |
# File 'lib/underpass/errors.rb', line 31 def http_status @http_status end |
Instance Method Details
#to_h ⇒ Hash
Returns a hash representation of the error.
51 52 53 54 55 56 57 |
# File 'lib/underpass/errors.rb', line 51 def to_h { code: code, message: , details: details } end |
#to_json ⇒ String
Returns a JSON representation of the error.
63 64 65 |
# File 'lib/underpass/errors.rb', line 63 def to_json(*) to_h.to_json(*) end |