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
- Loading branch information
1 parent
5305b41
commit a866312
Showing
14 changed files
with
66 additions
and
41 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
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,19 @@ | ||
package examples | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/bitcoin-sv/spv-wallet/models" | ||
) | ||
|
||
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