Exception: Supabase::Postgrest::Errors::APIError
- Inherits:
-
StandardError
- Object
- StandardError
- Supabase::Postgrest::Errors::APIError
- Defined in:
- lib/supabase/postgrest/errors.rb
Overview
Raised when the PostgREST server returns a non-success status. Mirrors supabase-py’s APIError — exposes :message, :code, :hint, :details plus the raw error hash via #raw.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#hint ⇒ Object
readonly
Returns the value of attribute hint.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
-
#initialize(error = {}) ⇒ APIError
constructor
A new instance of APIError.
-
#json ⇒ Hash
The raw error payload as received.
- #to_s ⇒ Object
Constructor Details
#initialize(error = {}) ⇒ APIError
Returns a new instance of APIError.
13 14 15 16 17 18 19 20 |
# File 'lib/supabase/postgrest/errors.rb', line 13 def initialize(error = {}) @raw = error || {} @message = @raw["message"] || @raw[:message] @code = @raw["code"] || @raw[:code] @hint = @raw["hint"] || @raw[:hint] @details = @raw["details"] || @raw[:details] super(to_s) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
10 11 12 |
# File 'lib/supabase/postgrest/errors.rb', line 10 def code @code end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
10 11 12 |
# File 'lib/supabase/postgrest/errors.rb', line 10 def details @details end |
#hint ⇒ Object (readonly)
Returns the value of attribute hint.
10 11 12 |
# File 'lib/supabase/postgrest/errors.rb', line 10 def hint @hint end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
10 11 12 |
# File 'lib/supabase/postgrest/errors.rb', line 10 def @message end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
10 11 12 |
# File 'lib/supabase/postgrest/errors.rb', line 10 def raw @raw end |
Instance Method Details
#json ⇒ Hash
Returns the raw error payload as received.
33 34 35 |
# File 'lib/supabase/postgrest/errors.rb', line 33 def json @raw end |
#to_s ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/supabase/postgrest/errors.rb', line 22 def to_s parts = [] parts << "Error #{@code}:" if @code parts << "\nMessage: #{@message}" if @message parts << "\nHint: #{@hint}" if @hint parts << "\nDetails: #{@details}" if @details result = parts.join result.empty? ? "Empty error" : result end |