generated from mrz1836/go-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(SPV-846): refactor examples to show extended errors (#249)
Co-authored-by: Krzysztof Tomecki <[email protected]>
- Loading branch information
1 parent
44c5921
commit c1170bf
Showing
15 changed files
with
76 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,20 +22,20 @@ func main() { | |
client := walletclient.NewWithXPriv(server, examples.ExampleXPriv) | ||
ctx := context.Background() | ||
|
||
recipient := walletclient.Recipients{To: "[email protected]", Satoshis: 1} | ||
recipient := walletclient.Recipients{To: "[email protected]", Satoshis: 1} | ||
recipients := []*walletclient.Recipients{&recipient} | ||
metadata := map[string]any{"some_metadata": "example"} | ||
|
||
newTransaction, err := client.SendToRecipients(ctx, recipients, metadata) | ||
if err != nil { | ||
fmt.Println(err) | ||
examples.GetFullErrorMessage(err) | ||
os.Exit(1) | ||
} | ||
fmt.Println("SendToRecipients response: ", newTransaction) | ||
|
||
tx, err := client.GetTransaction(ctx, newTransaction.ID) | ||
if err != nil { | ||
fmt.Println(err) | ||
examples.GetFullErrorMessage(err) | ||
os.Exit(1) | ||
} | ||
fmt.Println("GetTransaction response: ", tx) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package examples | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/bitcoin-sv/spv-wallet/models" | ||
) | ||
|
||
// GetFullErrorMessage prints detailed info about the error | ||
func GetFullErrorMessage(err error) { | ||
var errMsg string | ||
|
||
var spvError models.SPVError | ||
if errors.As(err, &spvError) { | ||
errMsg = fmt.Sprintf("Error, Message: %s, Code: %s, HTTP status code: %d", spvError.GetMessage(), spvError.GetCode(), spvError.GetStatusCode()) | ||
} else { | ||
errMsg = fmt.Sprintf("Error, Message: %s, Code: %s, HTTP status code: %d", err.Error(), models.UnknownErrorCode, 500) | ||
} | ||
fmt.Println(errMsg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters