-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8d5af8
commit 053df94
Showing
9 changed files
with
263 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"log" | ||
|
||
"github.com/m-mizutani/goerr" | ||
) | ||
|
||
var errInvalidInput = errors.New("invalid input") | ||
|
||
func someAction(input string) error { | ||
if input != "OK" { | ||
return goerr.Wrap(errInvalidInput, "input is not OK").With("input", input) | ||
} | ||
// ..... | ||
return nil | ||
} | ||
|
||
func main() { | ||
if err := someAction("ng"); err != nil { | ||
switch { | ||
case errors.Is(err, errInvalidInput): | ||
log.Printf("It's user's bad: %v\n", err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.