Skip to content

Commit

Permalink
errkit: nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar committed Jun 25, 2024
1 parent 08a61a6 commit bb8871e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion errkit/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ func (e ErrorX) MarshalJSON() ([]byte, error) {
for _, err := range e.errs {
tmp = append(tmp, err.Error())
}
if e.kind == nil {
e.kind = ErrKindUnknown
}
m := map[string]interface{}{
"kind": e.kind.String(),
"errors": tmp,
Expand Down Expand Up @@ -143,7 +146,7 @@ func (e *ErrorX) Cause() error {
// if any
func (e *ErrorX) Kind() ErrKind {
if e.kind == nil || e.kind.String() == "" {
return ErrKindUnknown
e.kind = ErrKindUnknown
}
return e.kind
}
Expand Down

0 comments on commit bb8871e

Please sign in to comment.