Documentation ¶
Index ¶
- func GetCode(err error) (code codes.Code)
- func GetConstraintName(err error) string
- func GetDetail(err error) string
- func GetHint(err error) string
- func WithCode(err error, code codes.Code) error
- func WithConstraintName(err error, constraint string) error
- func WithDetail(err error, detail string) error
- func WithHint(err error, hint string) error
- func WithSeverity(err error, severity Severity) error
- func WithSource(err error, file string, line int32, function string) error
- type Error
- type Severity
- type Source
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 GetDetail ¶ added in v0.4.0
GetDetail returns the Postgres detail inside the given error. If no error detail is an empty string returned.
func GetHint ¶ added in v0.4.0
GetHint returns the Postgres hint inside the given error. If no error hint is an empty string returned.
func WithConstraintName ¶
WithConstraintName decorates the error with a Postgres error constraint
func WithDetail ¶ added in v0.4.0
WithDetail decorates the error with Postgres error details
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.