Documentation ¶
Overview ¶
Package dberrors contains unified database Errors converted from third-party package errors.
In order to create the RESTful API that is indepenedent of the database type, the database errors must be converted into single form. This package defines database Errors with some Prototypes that are the most common error categories.
In order to maintaing uniform form of the error converting, every database driver should implement the 'Converter' interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Warnings ErrWarning = Error{ID: 1, Title: "Warning"} // ErrNoResult used as a replacement for ErrNoRows - for non-sql databases ErrNoResult = Error{ID: 2, Title: "No Result"} // Connection Exception ErrConnExc = Error{ID: 3, Title: "Connection exception"} ErrCardinalityViolation = Error{ID: 4, Title: "Cardinality violation"} // Data Exception ErrDataException = Error{ID: 5, Title: "Data Exception"} // Integrity Violation ErrIntegrConstViolation = Error{ID: 6, Title: "Integrity constraint violation"} ErrRestrictViolation = Error{ID: 7, Title: "Restrict violation"} ErrNotNullViolation = Error{ID: 8, Title: "Not null violation"} ErrForeignKeyViolation = Error{ID: 9, Title: "Foreign-Key violation"} ErrUniqueViolation = Error{ID: 10, Title: "Unique violation"} ErrCheckViolation = Error{ID: 11, Title: "Check violation"} // Transactions ErrInvalidTransState = Error{ID: 12, Title: "Invalid transaction state"} ErrInvalidTransTerm = Error{ID: 13, Title: "Invalid transaction termination"} ErrTransRollback = Error{ID: 14, Title: "Transaction Rollback"} // TxDone is an equivalent of sql.ErrTxDone error from sql package ErrTxDone = Error{ID: 15, Title: "Transaction done"} // Invalid Authorization ErrInvalidAuthorization = Error{ID: 16, Title: "Invalid Authorization Specification"} ErrInvalidPassword = Error{ID: 17, Title: "Invalid password"} // Invalid Schema Name ErrInvalidSchemaName = Error{ID: 18, Title: "Invalid Schema Name"} // Invalid Catalog Name ErrInvalidCatalogName = Error{ID: 19, Title: "Invalid Catalog Name"} // Syntax Error ErrInvalidSyntax = Error{ID: 20, Title: "Syntax Error"} ErrInsufficientPrivilege = Error{ID: 21, Title: "Insufficient Privilege"} // Insufficient Resources ErrInsufficientResources = Error{ID: 22, Title: "Insufficient Resources"} // Program Limit Exceeded ErrProgramLimitExceeded = Error{ID: 23, Title: "Program Limit Exceeded"} // System Error ErrSystemError = Error{ID: 24, Title: "System error"} // Internal Error ErrInternalError = Error{ID: 25, Title: "Internal error"} // Unspecified Error - all other errors not included in this division ErrUnspecifiedError = Error{ID: 26, Title: "Unspecified error"} )
Functions ¶
This section is empty.
Types ¶
type Converter ¶
Converter is an interface that defines the form of converting third-party database errors into uniform dberrors.Error. The returned errors should be based on the prototypes provided in this package.
type Error ¶
Error is a unified Database Error.
This package contain error prototypes with name starting with Err... On their base recogniser should create new errors. In order to compare the error entity with prototype use the 'Compare' method.
func (*Error) Compare ¶
Compare - checks if the error is of the same type as given in the argument
Error variables given in the package doesn't have details. Every *Error has its own Message. By comparing the error with Variables of type Error in the package the result will always be false This method allows to check if the error has the same ID as the error provided as an argument
func (*Error) GetPrototype ¶
GetPrototype returns the Error prototype on which the given database *Error entity was built.
func (Error) New ¶
New creates a copy of the given *Error Only ID and Title fields are copied to new Error the Message should be unique for given situation. Used on prototypes to create Prototype based Errors
func (Error) NewWithError ¶
NewWithError creates new Error copy based on the Error with a message. The message is an Error value from 'err' argument. Used on prototypes to create new prototype based Error containing a situation specific message based on provided error.
func (Error) NewWithMessage ¶
NewWithMessage creates new *Error copy of the Error with additional message. Used on prototypes to create new prototype based Error containing a situation specific message based on the given argument.