class PG::ServerError < PG::Error
An error the server reported (an ErrorResponse message): a failed statement, or a refused login. Its fields are the protocol's, by their one-letter codes; the common ones have readers.
Class methods
def self.new(fields: Hash[String, String]) -> PG::ServerError
An error with the server's fields.
def self.describe(fields: Hash[String, String]) -> String
ERROR 23505: duplicate key value ..., with the detail on a line of
its own.
PG::ServerError.describe({ "V" => "ERROR", "C" => "42P01", "M" => "no table" }) # => "ERROR 42P01: no table"
Methods
def fields -> Hash[String, String]
All the fields, by their codes (S severity, C SQLSTATE, M
message, D detail, H hint, P position, W where, s schema,
t table, c column, n constraint, ...).
def code -> String
The SQLSTATE code (23505 for a unique violation).
def severity -> String
ERROR, FATAL or PANIC (not localized).
def detail -> String?
The detail, if the server gave one.
def hint -> String?
The hint, if the server gave one.
def position -> Int?
Where in the statement the error is: a character position from 1.
def constraint -> String?
The constraint violated, if any.