Documentation
¶
Index ¶
Constants ¶
const ( UnknownInternalServerError = "01: Unknown Internal Server Error" Unauthenticated = "03: Authentication Failed" Forbidden = "04: Forbidden" )
const ( // PQErr23505UniqueViolation Postgres code for unique violation PQErr23505UniqueViolation = "23505" // PQErr58030IOError Postgres code for i/o error ("could not write to temporary file") PQErr58030IOError = "58030" // PQErr42P01 pq: relation "<string>" does not exist PQErr42P01 = "42P01" )
Variables ¶
This section is empty.
Functions ¶
func ContainsError ¶
ContainsError checks if the error contains the specified error message
func IsAnyPQError ¶
IsAnyPQError checks if the passed error is a Postgres error
func IsNoRowsPQError ¶
IsNoRowsPQError returns whether the error is a pg sql no rows found
func NewErr ¶
NewErr returns an error with the friendly user message from an ExtendedError, so it doesn't get logged
func Wrap ¶
Wrap checks if the passed error has been wrapped before by this func and either wraps the original error as an ExtendedError or adds the debug message to the already existing ExtendedError's InnerError. It will also overwrite the current ExtendedError's user message if the passed userMsg is not empty i.e. is it an ExtendedError. If not, it will create an ExtendedError, assign the InnerError and UserMsg to it and then return it. If it already is an ExtendedError
Types ¶
type ExtendedError ¶
type ExtendedError struct { InnerError error `json:"innerError"` UserMsg string `json:"userMsg"` TruncateXLines int // contains filtered or unexported fields }
ExtendedError is our custom error
var CustomExtendedError *ExtendedError = &ExtendedError{}
CustomExtendedError is the custom error object
func AsExtendedError ¶
func AsExtendedError(err error) (ee *ExtendedError)
AsExtendedError helper function that returns the error as an ExtendedError if it is one. Otherwise it returns nil
func (*ExtendedError) AsError ¶
func (e *ExtendedError) AsError(tgt interface{}) bool
AsError calls errors.As on the original error with the specified target error. If it is the target error, it will set the target as the original error value and return true, otherwise it returns false
func (*ExtendedError) Error ¶
func (e *ExtendedError) Error() string
Error returns the string of the inner error
func (*ExtendedError) IsError ¶
func (e *ExtendedError) IsError(tgt error) bool
IsError checks if the originating error is the specified target