Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

Awesome Lists containing this project

README

        

Install
------

```
$ go get github.com/y-matsuwitter/trycatch
```

Example
-----

```
package main

import "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")
}

```