SoXX
b8e29de4fc
- Replace custom error types with string constants for common database errors. - Simplify the Database struct to include a Reason field for error messages. - Update Error method to format the error output using the Reason. - Modify validation error constants for consistency and clarity.
20 lines
395 B
Go
20 lines
395 B
Go
package error
|
|
|
|
import "fmt"
|
|
|
|
const (
|
|
EntityAlreadyExists = "EntityAlreadyExists"
|
|
NoDataWritten = "NoDataWritten"
|
|
NoDataFound = "NoDataFound"
|
|
DatabaseIsNotConnected = "database is not connected"
|
|
DuplicateKey = "DuplicateKey"
|
|
)
|
|
|
|
type Database struct {
|
|
Reason string
|
|
}
|
|
|
|
func (e Database) Error() string {
|
|
return fmt.Sprintf("Database error: %s", e.Reason)
|
|
}
|