diff --git a/README.md b/README.md index 399f5fa..bfc2e5d 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ This error indicates that the request does not have valid authentication credent func SensitiveOperation(ctx context.Context) error { user, ok := user.FromContext(ctx) if !ok { - return nil, faults.Unauthenticated + return faults.Unauthenticated } // Perform operation @@ -147,10 +147,10 @@ It must not be used for rejections caused by exhausting some resource. It must a func SensitiveResource(ctx context.Context) error { user, ok := user.FromContext(ctx) if !ok { - return nil, faults.Unauthenticated + return faults.Unauthenticated } if !user.IsAdmin() { - return nil, faults.PermissionDenied + return faults.PermissionDenied } // Perform operation diff --git a/faults.go b/faults.go index b5e463a..1c3fb5e 100644 --- a/faults.go +++ b/faults.go @@ -89,6 +89,7 @@ func WithResourceExhausted(parent error, violations ...*QuotaViolation) error { return &QuotaFailure{parent, violations} } +// WithUnimplemented wraps `parent` with an `UnimplementedFailure` func WithUnimplemented(parent error) error { return &UnimplementedFailure{parent} }