Skip to content

Commit 9c2a89b

Browse files
authored
fix: use errors func instead of direct type assignment (#371)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 911ac19 commit 9c2a89b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

internal/api/localtxsubmission.go

Lines changed: 8 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.
@@ -15,6 +15,7 @@
1515
package api
1616

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

@@ -83,8 +84,12 @@ func handleLocalSubmitTx(c *gin.Context) {
8384
txHash, err := submit.SubmitTx(submitConfig, txRawBytes)
8485
if err != nil {
8586
if c.GetHeader("Accept") == "application/cbor" {
86-
txRejectErr := err.(localtxsubmission.TransactionRejectedError)
87-
c.Data(400, "application/cbor", txRejectErr.ReasonCbor)
87+
var txRejectErr *localtxsubmission.TransactionRejectedError
88+
if errors.As(err, &txRejectErr) {
89+
c.Data(400, "application/cbor", txRejectErr.ReasonCbor)
90+
} else {
91+
c.Data(500, "application/cbor", []byte{})
92+
}
8893
} else {
8994
if err.Error() != "" {
9095
c.JSON(400, err.Error())

0 commit comments

Comments
 (0)