mirror of
https://code.tvl.fyi/depot.git:/tools/nixery.git
synced 2025-03-14 21:51:52 +00:00
refactor(server): Handle non-error errors safely
This case should not be possible unless something manually constructs a logrus entry with a non-error value in the log.ErrorKey field, but it's better to be safe than sorry.
This commit is contained in:
parent
583715adc6
commit
8f48226b24
|
@ -76,11 +76,12 @@ func (f stackdriverFormatter) Format(e *log.Entry) ([]byte, error) {
|
||||||
msg["eventTime"] = &e.Time
|
msg["eventTime"] = &e.Time
|
||||||
msg["severity"] = logSeverity(e.Level)
|
msg["severity"] = logSeverity(e.Level)
|
||||||
|
|
||||||
if err, ok := msg[log.ErrorKey]; ok {
|
if e, ok := msg[log.ErrorKey]; ok {
|
||||||
// TODO(tazjin): Cast safely - for now there should be
|
if err, isError := e.(error); isError {
|
||||||
// no calls to `.WithError` with a nil error, but who
|
msg[log.ErrorKey] = err.Error()
|
||||||
// knows.
|
} else {
|
||||||
msg[log.ErrorKey] = (err.(error)).Error()
|
delete(msg, log.ErrorKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if isError(e) {
|
if isError(e) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user