From 1de1a2de1a6a1995e07e820f3a28a6081fedf954 Mon Sep 17 00:00:00 2001 From: Nathan Seva Date: Wed, 18 Oct 2023 07:54:23 -0500 Subject: [PATCH] fix error formating with nil pointers --- pkg/node/events.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pkg/node/events.go b/pkg/node/events.go index fe360adfc..6ca9a1849 100644 --- a/pkg/node/events.go +++ b/pkg/node/events.go @@ -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) + } }