Skip to content

Instantly share code, notes, and snippets.

@Jimeux
Created May 8, 2019 08:52
Show Gist options
  • Save Jimeux/de3eb5cf4b44cf37af9e2a80251130e8 to your computer and use it in GitHub Desktop.
Save Jimeux/de3eb5cf4b44cf37af9e2a80251130e8 to your computer and use it in GitHub Desktop.
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