errors

package
v2.22.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Select indicates a SELECT statement triggered the error
	Select SQLQueryType = "SELECT"
	// Insert indicates an INSERT statement triggered the error
	Insert = "INSERT"
	// Delete indicates a DELETE statement triggered the error
	Delete = "DELETE"
	// Update indicates an UPDATE statement triggered the error
	Update = "UPDATE"
)

Variables

This section is empty.

Functions

func DatabaseToApiError

func DatabaseToApiError(primary qb.Table, dbError error) error

DatabaseToApiError handles conversion from a database error to a GRPC friendly error with code.

func DatabaseToStatus added in v2.19.0

func DatabaseToStatus(primary qb.Table, dbError error) *status.Status

DatabaseToStatus translates the passed db error into a grpc Status with appropriate status code

func EqualLogError

func EqualLogError(assert assertion, theError error, errString string, msgAndArgs ...interface{}) bool

EqualLogError asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error, ignoring line number in the log prefix and any database error ids.

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns a boolean indicating that the passed error (can be nil) is of type *database.NotFoundError

func NewDataTooLongError

func NewDataTooLongError(action SQLQueryType, stmt string, err error) errors.TracerError

NewDataTooLongError wrapping the passer error with references to the passed sql statement and action

func NewDatabaseConnectionError

func NewDatabaseConnectionError(err error) errors.TracerError

NewDatabaseConnectionError instantiates a DatabaseConnectionError with a stack trace

func NewDuplicateRecordError

func NewDuplicateRecordError(action SQLQueryType, stmt string, err error) errors.TracerError

NewDuplicateRecordError is returned when a records is created/updated with a duplicate primary key

func NewExecutionError

func NewExecutionError(action SQLQueryType, stmt string, err error) errors.TracerError

NewExecutionError with wrapping the passed error with the passed action and sql statement

func NewInvalidForeignKeyError

func NewInvalidForeignKeyError(action SQLQueryType, stmt string, err error) errors.TracerError

NewInvalidForeignKeyError wrapping the passed error with references to the passed sql and action.

func NewNotAPointerError

func NewNotAPointerError() errors.TracerError

NewNotAPointerError instantiates a NotAPointerError with a stack trace

func NewNotFoundError

func NewNotFoundError() errors.TracerError

NewNotFoundError returns a NotFoundError with a stack trace

func NewSystemError

func NewSystemError(action SQLQueryType, stmt string, err error) errors.TracerError

NewSystemError returns an ExecutionError

func NewUniqueConstraintError

func NewUniqueConstraintError(action SQLQueryType, stmt string, err error) errors.TracerError

NewUniqueConstraintError is returned when a record is created/updated with a duplicate primary key

func NewValidationError

func NewValidationError(msg string, subs ...interface{}) errors.TracerError

NewValidationError returns a ValidationError with a stack trace

func TranslateError

func TranslateError(err error, action SQLQueryType, stmt string) errors.TracerError

TranslateError converts a mysql or other obtuse errors into discrete explicit errors

Types

type ConnectionError

type ConnectionError struct {
	// contains filtered or unexported fields
}

ConnectionError is returned when unable to connect to database

func (*ConnectionError) Error

func (err *ConnectionError) Error() string

func (*ConnectionError) Trace

func (err *ConnectionError) Trace() []string

Trace returns the stack trace for the error

type DataTooLongError

type DataTooLongError struct {
	SQLExecutionError
}

DataTooLongError is returned when a mysql error #1406 occurs

type DuplicateRecordError

type DuplicateRecordError struct {
	SQLExecutionError
}

DuplicateRecordError is returned when a mysql error #1062 occurs for a PrimaryKey

type InvalidForeignKeyError

type InvalidForeignKeyError struct {
	SQLExecutionError
}

InvalidForeignKeyError is returned when a mysql error #1452 occurs

type NotAPointerError

type NotAPointerError struct {
	// contains filtered or unexported fields
}

NotAPointerError indicates that a record object isn't a pointer

func (*NotAPointerError) Error

func (err *NotAPointerError) Error() string

func (*NotAPointerError) Trace

func (err *NotAPointerError) Trace() []string

Trace returns the stack trace for the error

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields
}

NotFoundError is returned when a query against the database fails

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error prints a NotFoundError

func (*NotFoundError) Trace

func (e *NotFoundError) Trace() []string

Trace returns the stack trace for the error

type SQLExecutionError

type SQLExecutionError struct {
	Action      SQLQueryType
	ReferenceID string

	Stmt   string
	ErrMsg string
	// contains filtered or unexported fields
}

SQLExecutionError is returned when a query against the database fails

func (*SQLExecutionError) Error

func (e *SQLExecutionError) Error() string

Error logs the reference id and statement for reference and returns a string representation of this error containing the reference ID

func (*SQLExecutionError) Trace

func (e *SQLExecutionError) Trace() []string

Trace returns the stack trace for the error

type SQLQueryType

type SQLQueryType string

SQLQueryType indicates the type of query being executed that caused an error

type SQLSystemError

type SQLSystemError struct {
	SQLExecutionError
}

SQLSystemError is returned when a database action fails

type UniqueConstraintError

type UniqueConstraintError struct {
	SQLExecutionError
}

UniqueConstraintError is returned when a mysql error #1062 occurs for a Unique constraint

type ValidationError

type ValidationError struct {
	// contains filtered or unexported fields
}

ValidationError is returned when a query against the database fails

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error prints a ValidationError

func (*ValidationError) Trace

func (e *ValidationError) Trace() []string

Trace returns the stack trace for the error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL