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 ( // ErrWarning is a warning message ErrWarning = Error{ID: 1, Title: "Warning"} // ErrNoResult used as a replacement for ErrNoRows - for non-sql databases ErrNoResult = Error{ID: 2, Title: "No Result"} // ErrConnection is an error thrown when there are problems with the database connection ErrConnection = Error{ID: 3, Title: "Connection exception"} // ErrCardinalityViolation is an error thrown when the cardinality of results fails // i.e. the result of subquery contains 4 fields whereas in the root query requires only 2 ErrCardinalityViolation = Error{ID: 4, Title: "Cardinality violation"} // ErrDataException data exception is the data format and integration error ErrDataException = Error{ID: 5, Title: "Data Exception"} // ErrIntegrityConstraintViolation is an error thrown when integrity constarint violation occurs ErrIntegrityConstraintViolation = Error{ID: 6, Title: "Integrity constraint violation"} // ErrRestrictViolation is an error thrown when the restricted violation is thrown ErrRestrictViolation = Error{ID: 7, Title: "Restrict violation"} // ErrNotNullViolation thrown when the NOT NULL restriction is violated ErrNotNullViolation = Error{ID: 8, Title: "Not null violation"} // ErrForeignKeyViolation error thrown when the Foreign Key is violated ErrForeignKeyViolation = Error{ID: 9, Title: "Foreign-Key violation"} // ErrUniqueViolation thrown when the restriction on the Uniqness is violated ErrUniqueViolation = Error{ID: 10, Title: "Unique violation"} // ErrCheckViolation thrown when any check on the data value is violated ErrCheckViolation = Error{ID: 11, Title: "Check violation"} // ErrTxState is an error thrown when the transaction is on invalid state ErrTxState = Error{ID: 12, Title: "Invalid transaction state"} // ErrTxTermination thrown when the transaction is already terminated ErrTxTermination = Error{ID: 13, Title: "Invalid transaction termination"} // ErrTxRollback thrown when the current transaction is already Rollbacked ErrTxRollback = Error{ID: 14, Title: "Transaction Rollback"} // ErrTxNotFound thrown when the transaction is not found ErrTxNotFound = Error{ID: 15, Title: "Transaction not found"} // ErrTxBeginInProgress thrown when the transaction Begin phase is still in progress ErrTxBeginInProgress = Error{ID: 16, Title: "Transaction in progress"} // ErrTxDone thrown when the transaction is already Done while trying to Commit the changes ErrTxDone = Error{ID: 15, Title: "Transaction done"} // ErrAuthorizationFailed thrown when the authorization process failed ErrAuthorizationFailed = Error{ID: 16, Title: "Invalid Authorization Specification"} // ErrAuthenticationFailed thrown when authentication failed while connecting to the database ErrAuthenticationFailed = Error{ID: 17, Title: "Authentication failed"} // ErrInvalidSchemaName thrown when the provided schema name doesn't exists ErrInvalidSchemaName = Error{ID: 18, Title: "Invalid Schema Name"} // ErrInvalidCatalogName thrown when the catalog name is invalid ErrInvalidCatalogName = Error{ID: 19, Title: "Invalid Catalog Name"} // ErrInvalidResourceName thrown when the resource name is not valid ErrInvalidResourceName = Error{ID: 28, Title: "Invalid Resource name"} // ErrInvalidSyntax thrown for an invalid syntax provided ErrInvalidSyntax = Error{ID: 20, Title: "Syntax Error"} // ErrInsufficientPrivilege thrown when the role has not sufficient privileges ErrInsufficientPrivilege = Error{ID: 21, Title: "Insufficient Privilege"} // ErrInsufficientResources thrown when the resources of the database is not sufficient for given query ErrInsufficientResources = Error{ID: 22, Title: "Insufficient Resources"} // ErrProgramLimitExceeded thrown when the database configuration limits are exceeded ErrProgramLimitExceeded = Error{ID: 23, Title: "Program Limit Exceeded"} // ErrSystemError thrown when there are errors with the system (i.e. I/O errors) ErrSystemError = Error{ID: 24, Title: "System error"} // ErrInternalError thrown on internal errors ErrInternalError = Error{ID: 25, Title: "Internal error"} // ErrUnspecifiedError - all other errors not included in this division ErrUnspecifiedError = Error{ID: 26, Title: "Unspecified error"} // ErrTimedOut when the query (not connection) is timed out ErrTimedOut = Error{ID: 27, Title: "Timed out"} // ErrReplica is the error that is thrown when there is a problem with replications ErrReplica = Error{ID: 29, Title: "Replica('s) error"} // ErrShutdown thrown when the database server is shutting down ErrShutdown = Error{ID: 32, Title: "Shutting down"} )
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.