mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 19:55:54 +00:00
chore(sample-docs): unify error handling with panic(err).
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Peersyst/xrpl-go/xrpl/faucet"
|
||||
"github.com/Peersyst/xrpl-go/xrpl/websocket"
|
||||
)
|
||||
@@ -20,8 +18,7 @@ func main() {
|
||||
|
||||
// Connect to the network
|
||||
if err := client.Connect(); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// ... custom code goes here
|
||||
|
||||
@@ -26,16 +26,14 @@ func main() {
|
||||
// Create a new wallet
|
||||
w, err := wallet.New(crypto.ED25519())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("New wallet created:")
|
||||
fmt.Println("Address:", w.ClassicAddress)
|
||||
|
||||
// Fund the wallet with testnet XRP
|
||||
if err := client.FundWallet(&w); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Get info from the ledger about the address we just funded
|
||||
@@ -43,8 +41,7 @@ func main() {
|
||||
Account: w.GetAddress(),
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Account Balance:", acc_info.AccountData.Balance)
|
||||
fmt.Println("Account Sequence:", acc_info.AccountData.Sequence)
|
||||
@@ -52,8 +49,7 @@ func main() {
|
||||
// Get info about the ledger
|
||||
ledger, err := client.GetLedger(&ledger.Request{LedgerIndex: common.Current})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Ledger Index:", ledger.Ledger.LedgerIndex)
|
||||
}
|
||||
|
||||
@@ -26,8 +26,7 @@ func main() {
|
||||
|
||||
// Connect to the network
|
||||
if err := client.Connect(); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if !client.IsConnected() {
|
||||
@@ -41,16 +40,14 @@ func main() {
|
||||
// Create a new wallet
|
||||
w, err := wallet.New(crypto.ED25519())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("New wallet created:")
|
||||
fmt.Println("Address:", w.ClassicAddress)
|
||||
|
||||
// Fund the wallet with testnet XRP
|
||||
if err := client.FundWallet(&w); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Get info from the ledger about the address we just funded
|
||||
@@ -58,8 +55,7 @@ func main() {
|
||||
Account: w.GetAddress(),
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Account Balance:", acc_info.AccountData.Balance)
|
||||
fmt.Println("Account Sequence:", acc_info.AccountData.Sequence)
|
||||
@@ -67,8 +63,7 @@ func main() {
|
||||
// Get info about the ledger
|
||||
ledger, err := client.GetLedger(&ledger.Request{LedgerIndex: common.Current})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Ledger Index:", ledger.Ledger.LedgerIndex)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user