Skip to content

Instantly share code, notes, and snippets.

@nicolasparada
Last active June 17, 2022 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolasparada/0c2e9e7b9855348bb51f0d8e49bffcf0 to your computer and use it in GitHub Desktop.
Save nicolasparada/0c2e9e7b9855348bb51f0d8e49bffcf0 to your computer and use it in GitHub Desktop.
package errs
const (
ErrUnauthenticated = UnauthenticatedError("unauthenticated")
ErrInvalidArgument = InvalidArgumentError("invalid argument")
ErrNotFound = NotFoundError("not found")
ErrConflict = ConflictError("conflict")
ErrPermissionDenied = PermissionDeniedError("permission denied")
ErrGone = GoneError("gone")
)
type UnauthenticatedError string
func (e UnauthenticatedError) Error() string { return string(e) }
func (e UnauthenticatedError) Is(target error) bool { return target == ErrUnauthenticated }
type InvalidArgumentError string
func (e InvalidArgumentError) Error() string { return string(e) }
func (e InvalidArgumentError) Is(target error) bool { return target == ErrInvalidArgument }
type NotFoundError string
func (e NotFoundError) Error() string { return string(e) }
func (e NotFoundError) Is(target error) bool { return target == ErrNotFound }
type ConflictError string
func (e ConflictError) Error() string { return string(e) }
func (e ConflictError) Is(target error) bool { return target == ErrConflict }
type PermissionDeniedError string
func (e PermissionDeniedError) Error() string { return string(e) }
func (e PermissionDeniedError) Is(target error) bool { return target == ErrPermissionDenied }
type GoneError string
func (e GoneError) Error() string { return string(e) }
func (e GoneError) Is(target error) bool { return target == ErrGone }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment