diff --git a/exception.go b/exception.go index 701c916..dbcc3f1 100644 --- a/exception.go +++ b/exception.go @@ -63,7 +63,7 @@ func (t *tryer) Ignore() Tryer { } // Finally initiates the call to the tried function and is always called after -// the function was executed, no matter if an exception occured or not. +// the function was executed, no matter if an exception occurred or not. func (t *tryer) Finally(finfn func()) { defer func() { defer finfn() @@ -136,7 +136,7 @@ func GetThrower() (bool, string, int) { cs := make([]uintptr, 20) amount := runtime.Callers(2, cs) usedThrower := false - var pfield *runtime.Func = nil + var pfield *runtime.Func for i := 0; i < amount; i++ { f := runtime.FuncForPC(cs[i]) diff --git a/exception_test.go b/exception_test.go index 517b66c..61e9177 100644 --- a/exception_test.go +++ b/exception_test.go @@ -9,7 +9,7 @@ import ( "testing" ) -func ExampleTry() { +func ExampleTry_finally() { exception.Try(func() { // do something if 1 == 2 { @@ -30,12 +30,13 @@ func ExampleTry() { } func someFuncThatMightGoWrongButDoesntMatter() {} -func ExampleIgnore() { + +func ExampleTry_ignore() { // will call the function but ignore all errors exception.Try(someFuncThatMightGoWrongButDoesntMatter).Ignore().Go() } -func ExampleGo() { +func ExampleTry_go() { // will throw an exception and catch it exception.Try(func() { exception.Throw("Something is wrong!")