Skip to content

Commit

Permalink
example (golang-basics): demo how to use ErrorWithCause(..)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka committed Jul 14, 2023
1 parent ffdb764 commit 7fe8d0a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions _examples/golang-basics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"log"
"net/http"

Expand Down Expand Up @@ -55,6 +56,9 @@ func (s *ExampleServiceRPC) GetUser(ctx context.Context, header map[string]strin
if userID == 911 {
return 0, nil, ErrUserNotFound
}
if userID == 31337 {
return 0, nil, ErrorWithCause(ErrUserNotFound, fmt.Errorf("unknown user id %d", userID))
}

return 200, &User{
ID: userID,
Expand Down

0 comments on commit 7fe8d0a

Please sign in to comment.