otter-space-sdk/pkg/error/database.go
SoXX b8e29de4fc refactor(error): error handling in database package
- 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.
2024-08-09 22:14:13 +02:00

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)
}