Created
May 8, 2019 08:52
-
-
Save Jimeux/de3eb5cf4b44cf37af9e2a80251130e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type DomainError struct { | |
prefix string | |
code int | |
msg string | |
} | |
func NewError(prefix string, code int, msg string) error { | |
return &DomainError{prefix: prefix, code: code, msg: msg} | |
} | |
func (e *DomainError) Error() string { | |
return fmt.Sprintf("[%s-%d]: %s", e.prefix, e.code, e.msg) | |
} | |
var ErrNotFound = NewError("user", 1, "user not found") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment