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.
22 lines
652 B
Go
22 lines
652 B
Go
package error
|
|
|
|
import "fmt"
|
|
|
|
const (
|
|
UserIDIsEmpty = "anthrovePostID cannot be empty"
|
|
UserIDToShort = "anthrovePostID needs to be 25 characters long"
|
|
SourceIDEmpty = "anthroveSourceID cannot be empty"
|
|
SourceIDToShort = "anthroveSourceID needs to be 25 characters long"
|
|
UserSourceIDEmpty = "anthroveUserSourceID cannot be empty"
|
|
UserSourceIDToShort = "anthroveUserSourceID needs to be 25 characters long"
|
|
TagIDEmpty = "tagID cannot be empty"
|
|
)
|
|
|
|
type EntityValidationFailed struct {
|
|
Reason string
|
|
}
|
|
|
|
func (e EntityValidationFailed) Error() string {
|
|
return fmt.Sprintf("Entity validation failed: %s", e.Reason)
|
|
}
|