Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/y-matsuwitter/trycatch
Golang try-catch syntax.
https://github.com/y-matsuwitter/trycatch
Last synced: 18 days ago
JSON representation
Golang try-catch syntax.
- Host: GitHub
- URL: https://github.com/y-matsuwitter/trycatch
- Owner: y-matsuwitter
- Created: 2014-05-04T00:56:35.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-04T01:25:08.000Z (over 10 years ago)
- Last Synced: 2023-03-23T00:57:04.653Z (almost 2 years ago)
- Language: Go
- Size: 121 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Install
------```
$ go get github.com/y-matsuwitter/trycatch
```Example
-----```
package mainimport "github.com/y-matsuwitter/trycatch"
type MyError struct {
error
}func main() {
trycatch.TryCatch{}.Try(func() {
println("do something buggy")
panic(MyError{})
}).Catch(MyError{}, func(err error) {
println("catch MyError")
}).CatchAll(func(err error) {
println("catch error")
}).Finally(func() {
println("finally do something")
})
println("done")
}```