Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goal: account info with deleted asset suppress error and better output #5504

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
minor, suppress error if asset not found
  • Loading branch information
ahangsu committed Jun 27, 2023
commit fc57c220927f31ec6dc41d86f5e21ad25adfb9b4
13 changes: 11 additions & 2 deletions cmd/goal/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package main
import (
"bufio"
"encoding/base64"
"errors"
"fmt"
"net/http"
"os"
"path/filepath"
"sort"
Expand All @@ -33,6 +35,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/crypto/passphrase"
apiClient "github.com/algorand/go-algorand/daemon/algod/api/client"
"github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/model"
algodAcct "github.com/algorand/go-algorand/data/account"
"github.com/algorand/go-algorand/data/basics"
Expand Down Expand Up @@ -630,8 +633,14 @@ func printAccountInfo(client libgoal.Client, address string, onlyShowAssetIds bo
assetParams, err := client.AssetInformation(assetHolding.AssetID)
if err != nil {
hasError = true
fmt.Fprintf(errorReport, "Error: Unable to retrieve asset information for asset %d referred to by account %s: %v\n", assetHolding.AssetID, address, err)
fmt.Fprintf(report, "\tID %d, error\n", assetHolding.AssetID)

var httpError apiClient.HTTPError
if errors.As(err, &httpError) && httpError.StatusCode == http.StatusNotFound {
fmt.Fprintf(report, "\tID %d, <deleted/unknown asset>\n", assetHolding.AssetID)
} else {
fmt.Fprintf(errorReport, "Error: Unable to retrieve asset information for asset %d referred to by account %s: %v\n", assetHolding.AssetID, address, err)
fmt.Fprintf(report, "\tID %d, error\n", assetHolding.AssetID)
}
}

amount := assetDecimalsFmt(assetHolding.Amount, assetParams.Params.Decimals)
Expand Down