Skip to content

Commit

Permalink
Merge pull request #453 from projectdiscovery/errkit-missing-nil-check
Browse files Browse the repository at this point in the history
errkit: nil check
  • Loading branch information
tarunKoyalwar authored Jun 27, 2024
2 parents 7720027 + bb8871e commit 5bb2161
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 5bb2161

Please sign in to comment.