From 91abab7b26ccdf8bc44ec6a4ececb34dab457786 Mon Sep 17 00:00:00 2001 From: basgys Date: Mon, 16 Mar 2026 01:56:32 +0100 Subject: [PATCH] fix: correct README examples and add missing godoc on WithUnimplemented Two README examples used 'return nil, fault' with a single-error return type. Add missing doc comment on WithUnimplemented to match all other With* functions. --- README.md | 6 +++--- faults.go | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) 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} }