a try package with a Catch to match
License
bjarneh/try
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
[ What ] A small catch package to turn a go panic into an os.Error, and get a nice stack trace to go. [ Install ] goinstall github.com/bjarneh/try [ Example ] <code> // a type switch on errors == almost readable func Caller() { e := ICanDoAnything() switch t := e.(type) { case nil: case *try.Error: t.Die(os.Stderr) case *another.Error: log.Fatalf("another: %s\n", t) case *constant.Error: log.Fatalf("constant: %s\n", t) default: log.Fatalf("os.Error %s\n", t) } } func ICanDoAnything() (error os.Error) { defer try.Catch(&error) // code that does something and perhaps panics // and in any case will return an os.Error return } </code>
About
a try package with a Catch to match
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published