Skip to content

Commit d4dd94c

Browse files
authored
fix: use errors to avoid fmt (#367)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 1168bce commit d4dd94c

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

internal/node/chainsync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package node
1616

1717
import (
18-
"fmt"
18+
"errors"
1919
"time"
2020

2121
"github.com/blinklabs-io/cardano-node-api/internal/config"
@@ -123,7 +123,7 @@ func chainSyncRollForwardHandler(
123123
}
124124
*/
125125
default:
126-
return fmt.Errorf("unknown block data")
126+
return errors.New("unknown block data")
127127
}
128128
}
129129
return nil

internal/node/node.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
1515
package node
1616

1717
import (
18+
"errors"
1819
"fmt"
1920
"os"
2021

@@ -69,7 +70,7 @@ func GetConnection(connCfg *ConnectionConfig) (*ouroboros.Connection, error) {
6970
return nil, fmt.Errorf("failure connecting to node via UNIX socket: %s", err)
7071
}
7172
} else {
72-
return nil, fmt.Errorf("you must specify either the UNIX socket path or the address/port for your cardano-node")
73+
return nil, errors.New("you must specify either the UNIX socket path or the address/port for your cardano-node")
7374
}
7475
return oConn, nil
7576
}

internal/utxorpc/submit.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package utxorpc
1717
import (
1818
"context"
1919
"encoding/hex"
20+
"errors"
2021
"fmt"
2122
"log"
2223
"log/slog"
@@ -179,7 +180,7 @@ func (s *submitServiceServer) WaitForTx(
179180
case evt, ok := <-eventChan:
180181
if !ok {
181182
logger.Error("Event channel closed unexpectedly.")
182-
return fmt.Errorf("event channel closed")
183+
return errors.New("event channel closed")
183184
}
184185

185186
// Process the event

internal/utxorpc/sync.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@ package utxorpc
1616

1717
import (
1818
"context"
19+
"errors"
1920
"fmt"
2021
"log"
2122

@@ -215,7 +216,7 @@ func (s *chainSyncServiceServer) FollowTip(
215216
evt, ok := <-eventChan
216217
if !ok {
217218
log.Printf("ERROR: channel closed")
218-
return fmt.Errorf("ERROR: channel closed")
219+
return errors.New("ERROR: channel closed")
219220
}
220221

221222
switch evt.Type {
@@ -225,7 +226,7 @@ func (s *chainSyncServiceServer) FollowTip(
225226
context := evt.Context
226227
if context == nil {
227228
log.Printf("ERROR: empty block context")
228-
return fmt.Errorf("ERROR: empty block context")
229+
return errors.New("ERROR: empty block context")
229230
}
230231
bc := context.(input_chainsync.BlockContext)
231232
// Get event payload to get the block data

internal/utxorpc/watch.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@ package utxorpc
1616

1717
import (
1818
"context"
19+
"errors"
1920
"fmt"
2021
"log"
2122

@@ -82,7 +83,7 @@ func (s *watchServiceServer) WatchTx(
8283
evt, ok := <-eventChan
8384
if !ok {
8485
log.Printf("ERROR: channel closed")
85-
return fmt.Errorf("ERROR: channel closed")
86+
return errors.New("ERROR: channel closed")
8687
}
8788

8889
switch evt.Type {
@@ -91,7 +92,7 @@ func (s *watchServiceServer) WatchTx(
9192
context := evt.Context
9293
if context == nil {
9394
log.Printf("ERROR: empty block context")
94-
return fmt.Errorf("ERROR: empty block context")
95+
return errors.New("ERROR: empty block context")
9596
}
9697
bc := context.(input_chainsync.BlockContext)
9798
// Get event payload to get the block data

0 commit comments

Comments
 (0)