Skip to content

Commit

Permalink
Use an anonymous function instead of method on payload
Browse files Browse the repository at this point in the history
  • Loading branch information
snikch committed Aug 18, 2015
1 parent 0acce03 commit 139d63f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 7 additions & 1 deletion notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ func (notifier *Notifier) Notify(err error, rawData ...interface{}) (e error) {
return (&payload{event, config}).deliver()
}
// Ensure that any errors are logged if they occur in a goroutine.
go (&payload{event, config}).deliverOrLog()
go func(event *Event, config *Configuration) {
err := (&payload{event, config}).deliver()
if err != nil {
config.log("bugsnag.Notify: %v", err)
}
}(event, config)

return nil
}
return fmt.Errorf("not notifying in %s", config.ReleaseStage)
Expand Down
7 changes: 0 additions & 7 deletions payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ func (p *payload) deliver() error {
return nil
}

func (p *payload) deliverOrLog() {
err := p.deliver()
if err != nil {
p.log("bugsnag.deliver: %v", err)
}
}

func (p *payload) MarshalJSON() ([]byte, error) {

data := hash{
Expand Down

0 comments on commit 139d63f

Please sign in to comment.