From d5420bd878295878681fac79e4cfb2ea28fb3954 Mon Sep 17 00:00:00 2001 From: Nathan Seva Date: Wed, 18 Oct 2023 09:30:16 -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..05cd16872 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 nil, listenEventError(operationID, caller, emitter) +} + +func listenEventError(operationID *string, caller *string, emitter *string) 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 fmt.Errorf(err) + } + + return fmt.Errorf( + "timeout while listening events for: opId %s, caller %s, emitter %s", *operationID, *caller, *emitter) }