Skip to content

Commit

Permalink
handel nil context value in field.FromContext() func (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
SupriyaKasten authored and mergify[bot] committed Sep 19, 2019
1 parent 4decc20 commit bd447e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/field/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ const ctxKey = contextKey(43)

// FromContext returns the fields present in ctx if any
func FromContext(ctx context.Context) Fields {
if s, ok := ctx.Value(ctxKey).(Fields); ok {
return s
if ctx != nil {
if s, ok := ctx.Value(ctxKey).(Fields); ok {
return s
}
}
return nil
}
Expand Down

0 comments on commit bd447e0

Please sign in to comment.