From 7d81ef01c25348f9f0b6babfd515df23382ce424 Mon Sep 17 00:00:00 2001 From: AllanCapistrano Date: Sun, 17 Sep 2023 14:46:36 -0300 Subject: [PATCH] chore: returning errors --- info/getNodeInfo.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/info/getNodeInfo.go b/info/getNodeInfo.go index f48928e..0ade3ee 100644 --- a/info/getNodeInfo.go +++ b/info/getNodeInfo.go @@ -2,7 +2,7 @@ package info import ( "context" - "log" + "errors" iotago "github.com/iotaledger/iota.go/v2" ) @@ -23,12 +23,12 @@ type Milestone struct { } // Get Tangle Hornet Network node information. -func GetNodeInfo(nodeUrl string) NodeInfo { +func GetNodeInfo(nodeUrl string) (NodeInfo, error) { node := iotago.NewNodeHTTPAPIClient(nodeUrl) info, err := node.Info(context.Background()) if err != nil { - log.Fatal("Unable to get node information.") + return NodeInfo{}, errors.New("unable to get node information") } milestone := &Milestone{ @@ -37,7 +37,7 @@ func GetNodeInfo(nodeUrl string) NodeInfo { LatestMilestoneTimestamp: info.LatestMilestoneTimestamp, } - return NodeInfo{ + nodeInfo := &NodeInfo{ Name: info.Name, NetworkId: info.NetworkID, Version: info.Version, @@ -45,4 +45,6 @@ func GetNodeInfo(nodeUrl string) NodeInfo { Milestone: *milestone, IsHealthy: info.IsHealthy, } + + return *nodeInfo, nil }