Skip to content

Commit 91abab7

Browse files
committed
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.
1 parent 9263491 commit 91abab7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This error indicates that the request does not have valid authentication credent
5757
func SensitiveOperation(ctx context.Context) error {
5858
user, ok := user.FromContext(ctx)
5959
if !ok {
60-
return nil, faults.Unauthenticated
60+
return faults.Unauthenticated
6161
}
6262

6363
// Perform operation
@@ -147,10 +147,10 @@ It must not be used for rejections caused by exhausting some resource. It must a
147147
func SensitiveResource(ctx context.Context) error {
148148
user, ok := user.FromContext(ctx)
149149
if !ok {
150-
return nil, faults.Unauthenticated
150+
return faults.Unauthenticated
151151
}
152152
if !user.IsAdmin() {
153-
return nil, faults.PermissionDenied
153+
return faults.PermissionDenied
154154
}
155155

156156
// Perform operation

faults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func WithResourceExhausted(parent error, violations ...*QuotaViolation) error {
8989
return &QuotaFailure{parent, violations}
9090
}
9191

92+
// WithUnimplemented wraps `parent` with an `UnimplementedFailure`
9293
func WithUnimplemented(parent error) error {
9394
return &UnimplementedFailure{parent}
9495
}

0 commit comments

Comments
 (0)