@@ -12,7 +12,7 @@ import (
1212 "github.com/pkg/errors"
1313)
1414
15- var ErrorNodeNotFround = fmt .Errorf ("failed to get requested node from node regiatrar " )
15+ var ErrorNodeNotFound = fmt .Errorf ("failed to get requested node from node registrar " )
1616
1717func (c * RegistrarClient ) RegisterNode (
1818 farmID uint64 ,
@@ -219,11 +219,15 @@ func (c *RegistrarClient) registerNode(
219219 return nodeID , errors .Wrap (err , "failed to send request to registrer the node" )
220220 }
221221
222- if resp == nil || resp .StatusCode != http .StatusCreated {
222+ if resp == nil {
223+ return 0 , errors .New ("no response received" )
224+ }
225+ defer resp .Body .Close ()
226+
227+ if resp .StatusCode != http .StatusCreated {
223228 err = parseResponseError (resp .Body )
224229 return 0 , errors .Wrapf (err , "failed to create node on the registrar with status code %s" , resp .Status )
225230 }
226- defer resp .Body .Close ()
227231
228232 result := struct {
229233 NodeID uint64 `json:"node_id"`
@@ -341,7 +345,7 @@ func (c *RegistrarClient) getNode(id uint64) (node Node, err error) {
341345 }
342346
343347 if resp .StatusCode == http .StatusNotFound {
344- return node , ErrorNodeNotFround
348+ return node , ErrorNodeNotFound
345349 }
346350
347351 if resp .StatusCode != http .StatusOK {
@@ -365,7 +369,7 @@ func (c *RegistrarClient) getNodeByTwinID(id uint64) (node Node, err error) {
365369 }
366370
367371 if len (nodes ) == 0 {
368- return node , ErrorNodeNotFround
372+ return node , ErrorNodeNotFound
369373 }
370374
371375 return nodes [0 ], nil
@@ -401,7 +405,7 @@ func (c *RegistrarClient) listNodes(opts []ListNodeOpts) (nodes []Node, err erro
401405 }
402406
403407 if resp .StatusCode == http .StatusNotFound {
404- return nodes , ErrorNodeNotFround
408+ return nodes , ErrorNodeNotFound
405409 }
406410
407411 if resp .StatusCode != http .StatusOK {
0 commit comments