Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCode ¶
GetCode returns the Postgres error code inside the given error. If no error code is found a Uncategorized error code returned.
func GetConstraintName ¶
GetConstraintName returns the Postgres error constraint name inside the given error.
func WithConstraintName ¶
WithConstraintName decorates the error with a Postgres error constraint
func WithSeverity ¶
WithSeverity decorates the error with a Postgres error severity
Types ¶
type Error ¶
type Error struct {
Code codes.Code
Message string
Detail string
Hint string
Severity Severity
ConstraintName string
Source *Source
}
Error contains all Postgres wire protocol error fields. See https://www.postgresql.org/docs/current/static/protocol-error-fields.html for a list of all Postgres error fields, most of which are optional and can be used to provide auxiliary error information.
type Severity ¶
type Severity string
Severity represents the severity of a thrown error. The possible error severities are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message)
const ( LevelError Severity = "ERROR" LevelFatal Severity = "FATAL" LevelPanic Severity = "PANIC" LevelWarning Severity = "WARNING" LevelNotice Severity = "NOTICE" LevelDebug Severity = "DEBUG" LevelInfo Severity = "INFO" LevelLog Severity = "LOG" )
Represents the severity of a thrown error. The possible error severities are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message)
func DefaultSeverity ¶
DefaultSeverity returns the default severity (ERROR) if no valid severity has been defined.
func GetSeverity ¶
GetSeverity returns the Postgres error severity inside the given error.