Skip to content

Commit

Permalink
chore: update example
Browse files Browse the repository at this point in the history
  • Loading branch information
wst24365888 committed Jan 12, 2022
1 parent aa5cef0 commit bb111f4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .examples/catch_on_different_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
. "github.com/ez4o/go-try"
)

type Test struct {
val int
}

func main() {
Try(func() {
ThrowOnError(1)
Expand All @@ -22,4 +26,10 @@ func main() {
}).Catch(func(i int) {
fmt.Println("This is an int exception:", i)
})

Try(func() {
ThrowOnError(Test{1})
}).Catch(func(t Test) {
fmt.Println("This is a Test exception:", t)
})
}

0 comments on commit bb111f4

Please sign in to comment.