Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from filecoin-project/fix/invalid-fil-address-…
Browse files Browse the repository at this point in the history
…handling

fix: use os.Exit instead of panic for user errors
  • Loading branch information
bajtos authored Jul 13, 2022
2 parents 8febc34 + 9f41f76 commit 615060d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ func main() {
var err error
port, err = strconv.Atoi(portStr)
if err != nil {
panic(fmt.Errorf("Invalid PORT value '%s': %s", portStr, err.Error()))
fmt.Fprintf(os.Stderr, "Invalid PORT value '%s': %s\n", portStr, err.Error())
os.Exit(1)
}
}

filAddr := os.Getenv("FIL_WALLET_ADDRESS")
if filAddr == "" {
panic(errors.New("no FIL_WALLET_ADDRESS provided"))
fmt.Fprintf(os.Stderr, "No FIL_WALLET_ADDRESS provided. Please set the environment variable.\n")
os.Exit(2)
}
if _, err := address.NewFromString(filAddr); err != nil {
panic(fmt.Errorf("invalid FIL_WALLET_ADDRESS format: %s", err.Error()))
fmt.Fprintf(os.Stderr, "Invalid FIL_WALLET_ADDRESS format: %s\n", err.Error())
os.Exit(3)
}
conf, err := json.Marshal(config{FilAddr: filAddr})
if err != nil {
Expand Down

0 comments on commit 615060d

Please sign in to comment.