Skip to content

Commit

Permalink
add useful error when API URL not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Duchesneau committed Apr 24, 2020
1 parent 7a3e18b commit 7430836
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

```bash
go get -u -v github.com/eoscanada/eosc/eosc

```


Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ place.


## Cryptographic primitives used
-----------------------------

The cryptography used is NaCl
([C implementation](https://tweetnacl.cr.yp.to/), [Javascript port](https://github.com/dchest/tweetnacl-js),
Expand Down
3 changes: 3 additions & 0 deletions eosc/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ func sanitizeAPIURL(input string) string {
func errorCheck(prefix string, err error) {
if err != nil {
fmt.Printf("ERROR: %s: %s\n", prefix, err)
if strings.HasSuffix(err.Error(), "connection refused") && strings.Contains(err.Error(), defaultAPIURL) {
fmt.Println("Have you selected a valid EOS HTTP endpoint ? You can use the --api-url flag or EOSC_GLOBAL_API_URL environment variable.")
}
os.Exit(1)
}
}
Expand Down
4 changes: 3 additions & 1 deletion eosc/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
// Version represents the eosc command version
var Version string

const defaultAPIURL = "http://localhost:8888"

// RootCmd represents the eosc command
var RootCmd = &cobra.Command{
Use: "eosc",
Expand Down Expand Up @@ -47,7 +49,7 @@ func init() {
RootCmd.PersistentFlags().BoolP("debug", "", false, "Enables verbose API debug messages")
RootCmd.PersistentFlags().StringP("vault-file", "", "./eosc-vault.json", "Wallet file that contains encrypted key material")
RootCmd.PersistentFlags().StringSliceP("wallet-url", "", []string{}, "Base URL to wallet endpoint. You can pass this multiple times to use the multi-signer (will use each wallet to sign multi-sig transactions).")
RootCmd.PersistentFlags().StringP("api-url", "u", "http://localhost:8888", "API endpoint of eos.io blockchain node")
RootCmd.PersistentFlags().StringP("api-url", "u", defaultAPIURL, "API endpoint of eos.io blockchain node")
RootCmd.PersistentFlags().StringSliceP("permission", "p", []string{}, "Permission to sign transactions with. Optionally specify more than one, or separate by comma")
RootCmd.PersistentFlags().StringSliceP("http-header", "H", []string{}, "HTTP header to add to a request. Optionally repeat this option to specify multiple headers")
RootCmd.PersistentFlags().StringP("kms-gcp-keypath", "", "", "Path to the cryptoKeys within a keyRing on GCP")
Expand Down

0 comments on commit 7430836

Please sign in to comment.