diff --git a/pkg/error/database.go b/pkg/error/database.go index 278a043..c372d14 100644 --- a/pkg/error/database.go +++ b/pkg/error/database.go @@ -1,25 +1,19 @@ package error -type EntityAlreadyExists struct{} +import "fmt" -func (e *EntityAlreadyExists) Error() string { - return "EntityAlreadyExists error" +const ( + EntityAlreadyExists = "EntityAlreadyExists" + NoDataWritten = "NoDataWritten" + NoDataFound = "NoDataFound" + DatabaseIsNotConnected = "database is not connected" + DuplicateKey = "DuplicateKey" +) + +type Database struct { + Reason string } -type NoDataWritten struct{} - -func (e *NoDataWritten) Error() string { - return "NoDataWritten error" -} - -type NoDataFound struct{} - -func (e *NoDataFound) Error() string { - return "NoDataFound error" -} - -type NoRelationCreated struct{} - -func (e *NoRelationCreated) Error() string { - return "relationship creation error" +func (e Database) Error() string { + return fmt.Sprintf("Database error: %s", e.Reason) } diff --git a/pkg/error/validation.go b/pkg/error/validation.go index 27ec3c4..6140443 100644 --- a/pkg/error/validation.go +++ b/pkg/error/validation.go @@ -3,11 +3,13 @@ package error import "fmt" const ( - AnthroveUserIDIsEmpty = "anthrovePostID cannot be empty" - AnthroveUserIDToShort = "anthrovePostID needs to be 25 characters long" - AnthroveSourceIDEmpty = "anthroveSourceID cannot be empty" - AnthroveSourceIDToShort = "anthroveSourceID needs to be 25 characters long" - AnthroveTagIDEmpty = "tagID cannot be empty" + 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 {