Skip to content

Commit

Permalink
fix error formating with nil pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
Thykof committed Oct 18, 2023
1 parent 4e18860 commit 1de1a2d
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions pkg/node/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,28 @@ func ListenEvents(
}
}

return nil,
fmt.Errorf("listening events for: opId %s, caller %s, emitter %s: Timeout", *operationID, *caller, *emitter)
// Handle the case where one or more pointers are nil
return listenEventError(operationID, caller, emitter)
}

func listenEventError(operationID *string, caller *string, emitter *string) ([]Event, error) {
if operationID == nil || caller == nil || emitter == nil {
err := "timeout while listening events for: "
if operationID == nil {
err += "operationID is nil, "
}

if caller == nil {
err += "caller is nil, "
}

if emitter == nil {
err += "emitter is nil, "
}

return nil, fmt.Errorf(err)
} else {
return nil, fmt.Errorf(
"timeout while listening events for: opId %s, caller %s, emitter %s", *operationID, *caller, *emitter)
}
}

0 comments on commit 1de1a2d

Please sign in to comment.