From e7bed36c17d9c3303b834d79d67c8ca9b17ab86f Mon Sep 17 00:00:00 2001 From: Timo Reitz Date: Sun, 8 Oct 2017 21:56:04 +0200 Subject: [PATCH 1/4] Fix typo in comment. --- exception.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exception.go b/exception.go index 701c916..404b642 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() From 97aab99f6f924f0fdb09b2b22799851fad7a1be7 Mon Sep 17 00:00:00 2001 From: Timo Reitz Date: Sun, 8 Oct 2017 21:57:02 +0200 Subject: [PATCH 2/4] Remove explicit zero value. --- exception.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exception.go b/exception.go index 404b642..dbcc3f1 100644 --- a/exception.go +++ b/exception.go @@ -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]) From ecece02e85aa64fbe87004b3552f8951fbe92a23 Mon Sep 17 00:00:00 2001 From: Timo Reitz Date: Sun, 8 Oct 2017 21:59:09 +0200 Subject: [PATCH 3/4] Add newline for clarity (let all functions be divided by enough space). --- exception_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/exception_test.go b/exception_test.go index 517b66c..2f400b4 100644 --- a/exception_test.go +++ b/exception_test.go @@ -30,6 +30,7 @@ func ExampleTry() { } func someFuncThatMightGoWrongButDoesntMatter() {} + func ExampleIgnore() { // will call the function but ignore all errors exception.Try(someFuncThatMightGoWrongButDoesntMatter).Ignore().Go() From be9606e7d6ca319c84656b96224cb26dd2107376 Mon Sep 17 00:00:00 2001 From: Timo Reitz Date: Sun, 8 Oct 2017 22:06:27 +0200 Subject: [PATCH 4/4] Rename example functions so they a) are included in the docs (via godoc) and b) contain information what they are examples about. --- exception_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exception_test.go b/exception_test.go index 2f400b4..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 { @@ -31,12 +31,12 @@ 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!")