otter-space-sdk/pkg/error/validation.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

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