Documentation ¶
Index ¶
- Constants
- func DatabaseToApiError(primary qb.Table, dbError error) error
- func EqualLogError(assert assertion, theError error, errString string, msgAndArgs ...interface{}) bool
- func IsNotFoundError(err error) bool
- func NewDataTooLongError(action SQLQueryType, stmt string, err error) errors.TracerError
- func NewDatabaseConnectionError(err error) errors.TracerError
- func NewDuplicateRecordError(action SQLQueryType, stmt string, err error) errors.TracerError
- func NewExecutionError(action SQLQueryType, stmt string, err error) errors.TracerError
- func NewInvalidForeignKeyError(action SQLQueryType, stmt string, err error) errors.TracerError
- func NewNotAPointerError() errors.TracerError
- func NewNotFoundError() errors.TracerError
- func NewSystemError(action SQLQueryType, stmt string, err error) errors.TracerError
- func NewUniqueConstraintError(action SQLQueryType, stmt string, err error) errors.TracerError
- func NewValidationError(msg string, subs ...interface{}) errors.TracerError
- func TranslateError(err error, action SQLQueryType, stmt string) errors.TracerError
- type ConnectionError
- type DataTooLongError
- type DuplicateRecordError
- type InvalidForeignKeyError
- type NotAPointerError
- type NotFoundError
- type SQLExecutionError
- type SQLQueryType
- type SQLSystemError
- type UniqueConstraintError
- type ValidationError
Constants ¶
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 ¶
DatabaseToApiError handles conversion from a database error to a GRPC friendly error with 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 ¶
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 and returns an instantiated DataTooLongError
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 and returns an ExecutionError
func NewInvalidForeignKeyError ¶
func NewInvalidForeignKeyError(action SQLQueryType, stmt string, err error) errors.TracerError
NewInvalidForeignKeyError logs the error and returns an instantiated InvalidForeignKeyError
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) 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 prints a ExecutionError
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