2019-03-19 19:11:26 +00:00
|
|
|
package postgres
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
BeginTransactionFailedMsg = "failed to begin transaction"
|
|
|
|
DbConnectionFailedMsg = "db connection failed"
|
|
|
|
DeleteQueryFailedMsg = "delete query failed"
|
|
|
|
InsertQueryFailedMsg = "insert query failed"
|
|
|
|
SettingNodeFailedMsg = "unable to set db node"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ErrBeginTransactionFailed(beginErr error) error {
|
|
|
|
return formatError(BeginTransactionFailedMsg, beginErr.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
func ErrDBConnectionFailed(connectErr error) error {
|
|
|
|
return formatError(DbConnectionFailedMsg, connectErr.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
func ErrDBDeleteFailed(deleteErr error) error {
|
|
|
|
return formatError(DeleteQueryFailedMsg, deleteErr.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
func ErrDBInsertFailed(insertErr error) error {
|
|
|
|
return formatError(InsertQueryFailedMsg, insertErr.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
func ErrUnableToSetNode(setErr error) error {
|
|
|
|
return formatError(SettingNodeFailedMsg, setErr.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
func formatError(msg, err string) error {
|
2019-10-18 15:20:53 +00:00
|
|
|
return fmt.Errorf("%s: %s", msg, err)
|
2019-03-19 19:11:26 +00:00
|
|
|
}
|