Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error instead of panic #8

Open
trotha01 opened this issue Aug 31, 2016 · 0 comments
Open

Return error instead of panic #8

trotha01 opened this issue Aug 31, 2016 · 0 comments

Comments

@trotha01
Copy link

We should return an error, instead of panic'ing.
Since this is a library, we should let the caller deal with the error.

For example, when calling parse.Recipients() on a message with an empty To list:

(process:24446): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
panic: ZERO pointer

goroutine 25 [running]:
panic(0x42edfa0, 0xc8201b8d10)
        /usr/local/go/src/runtime/panic.go:464 +0x3e6
github.com/sendgrid/go-gmime/gmime.ref(0x0)
        /Users/trevorrothaus/go/src/github.com/sendgrid/go-gmime/gmime/gmime.go:48 +0x75
github.com/sendgrid/go-gmime/gmime.AssignJanitor(0x5e00158, 0xc8201b46a8)
        /Users/trevorrothaus/go/src/github.com/sendgrid/go-gmime/gmime/janitor.go:22 +0x39
github.com/sendgrid/go-gmime/gmime.CastPointer(0x0, 0x41c719f)
        /Users/trevorrothaus/go/src/github.com/sendgrid/go-gmime/gmime/janitor.go:34 +0x81
github.com/sendgrid/go-gmime/gmime.CastInternetAddressList(0x0, 0x44bc748)
        /Users/trevorrothaus/go/src/github.com/sendgrid/go-gmime/gmime/internet_address.go:189 +0x21
github.com/sendgrid/go-gmime/gmime.(*aMessage).AllRecipients(0xc8201b45e8, 0x0)
        /Users/trevorrothaus/go/src/github.com/sendgrid/go-gmime/gmime/message.go:152 +0xc2
github.com/sendgrid/go-gmime/gmime.(*aParse).Recipients(0xc8201b8cd0, 0x0, 0x0)
        /Users/trevorrothaus/go/src/github.com/sendgrid/go-gmime/gmime/parse.go:64 +0x45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant