Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exception.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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])
Expand Down
7 changes: 4 additions & 3 deletions exception_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
)

func ExampleTry() {
func ExampleTry_finally() {
exception.Try(func() {
// do something
if 1 == 2 {
Expand All @@ -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!")
Expand Down