Exception: Poodle::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Poodle::Error
- Defined in:
- lib/poodle/errors/base_error.rb
Overview
Base exception class for all Poodle SDK errors
Direct Known Subclasses
AuthenticationError, ForbiddenError, NetworkError, PaymentError, RateLimitError, ServerError, ValidationError
Instance Attribute Summary collapse
-
#context ⇒ Hash
readonly
Additional context information about the error.
-
#status_code ⇒ Integer?
readonly
HTTP status code if available.
Instance Method Summary collapse
-
#initialize(message = "", context: {}, status_code: nil) ⇒ Error
constructor
Initialize a new error.
-
#message ⇒ String
Get the original error message without formatting.
-
#to_s ⇒ String
Get a string representation of the error with context.
Constructor Details
#initialize(message = "", context: {}, status_code: nil) ⇒ Error
Initialize a new error
25 26 27 28 29 30 |
# File 'lib/poodle/errors/base_error.rb', line 25 def initialize( = "", context: {}, status_code: nil) @original_message = super() @context = context @status_code = status_code end |
Instance Attribute Details
#context ⇒ Hash (readonly)
Returns additional context information about the error.
15 16 17 |
# File 'lib/poodle/errors/base_error.rb', line 15 def context @context end |
#status_code ⇒ Integer? (readonly)
Returns HTTP status code if available.
18 19 20 |
# File 'lib/poodle/errors/base_error.rb', line 18 def status_code @status_code end |
Instance Method Details
#message ⇒ String
Get the original error message without formatting
35 36 37 |
# File 'lib/poodle/errors/base_error.rb', line 35 def @original_message end |
#to_s ⇒ String
Get a string representation of the error with context
42 43 44 45 46 47 |
# File 'lib/poodle/errors/base_error.rb', line 42 def to_s result = @original_message result += " (Status: #{@status_code})" if @status_code result += " Context: #{@context}" unless @context.empty? result end |