Added errors for services
This commit is contained in:
parent
ab4b53fd40
commit
c3c3d65d32
12 changed files with 217 additions and 86 deletions
15
internal/application/errors/already_exists_error.go
Normal file
15
internal/application/errors/already_exists_error.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package errors
|
||||
|
||||
type AlreadyExistsError struct {
|
||||
msg string
|
||||
}
|
||||
|
||||
func NewAlreadyExistsError(msg string) *AlreadyExistsError {
|
||||
return &AlreadyExistsError{
|
||||
msg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *AlreadyExistsError) Error() string {
|
||||
return "Already exists: " + e.msg
|
||||
}
|
||||
|
|
@ -4,12 +4,12 @@ type DBError struct {
|
|||
msg string
|
||||
}
|
||||
|
||||
func NewDBError(msg string) DBError {
|
||||
return DBError{
|
||||
func NewDBError(msg string) *DBError {
|
||||
return &DBError{
|
||||
msg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *DBError) Error() string {
|
||||
return e.msg
|
||||
return "Database error:" + e.msg
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ func NewNotFoundError(msg string) *NotFoundError {
|
|||
}
|
||||
|
||||
func (e *NotFoundError) Error() string {
|
||||
return e.msg
|
||||
return "Not found error: " + e.msg
|
||||
}
|
||||
|
|
|
|||
15
internal/application/errors/validation_error.go
Normal file
15
internal/application/errors/validation_error.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package errors
|
||||
|
||||
type ValidationError struct {
|
||||
msg string
|
||||
}
|
||||
|
||||
func NewValidationError(msg string) *ValidationError {
|
||||
return &ValidationError{
|
||||
msg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ValidationError) Error() string {
|
||||
return "Validation error: " + e.msg
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue