Created
September 13, 2019 17:33
-
-
Save joshuap/f12910fda3e1e7a118d2d255ae9b05cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "errors" | |
import "fmt" | |
import "github.com/honeybadger-io/honeybadger-go" | |
func notifyHoneybadger(err error) { | |
if err == nil { | |
return | |
} | |
honeybadger.Notify(err) | |
} | |
func main() { | |
honeybadger.Configure(honeybadger.Configuration{APIKey: "api key here"}) | |
honeybadger.BeforeNotify( | |
func(notice *honeybadger.Notice) error { | |
if notice.ErrorClass == "errors.errorString" || | |
notice.ErrorClass == "errors.fundamental" || | |
notice.ErrorClass == "errors.withStack" { | |
notice.Fingerprint = notice.ErrorMessage | |
} | |
fmt.Println(notice.ErrorClass) | |
fmt.Println(notice.ErrorMessage) | |
fmt.Println(notice.Fingerprint) | |
return nil | |
}, | |
) | |
err := errors.New("unable to parse get transaction response: unexpected end of JSON input") | |
notifyHoneybadger(err) | |
fmt.Println("done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment