forked from mirror/logrus
Merge pull request #40 from aybabtme/assert-type-avoid-panics
Checks that the `error` field is really of `error` type.
This commit is contained in:
commit
23c2cf5a8b
|
@ -24,11 +24,21 @@ func (hook *AirbrakeHook) Fire(entry *logrus.Entry) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err := airbrake.Notify(entry.Data["error"].(error))
|
err, ok := entry.Data["error"].(error)
|
||||||
if err != nil {
|
if !ok {
|
||||||
entry.Logger.WithFields(logrus.Fields{
|
entry.Logger.WithFields(logrus.Fields{
|
||||||
"source": "airbrake",
|
"source": "airbrake",
|
||||||
"endpoint": airbrake.Endpoint,
|
"endpoint": airbrake.Endpoint,
|
||||||
|
}).Warn("Exceptions sent to Airbrake must have an `error` key of type `error`")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
airErr := airbrake.Notify(err)
|
||||||
|
if airErr != nil {
|
||||||
|
entry.Logger.WithFields(logrus.Fields{
|
||||||
|
"source": "airbrake",
|
||||||
|
"endpoint": airbrake.Endpoint,
|
||||||
|
"error": airErr,
|
||||||
}).Warn("Failed to send error to Airbrake")
|
}).Warn("Failed to send error to Airbrake")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue