diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-12-07 17:45:29 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-12-07 17:45:29 +0100 |
commit | 8f2364c22218754ae61cbf1ff9a5897573b43d62 (patch) | |
tree | 0639d96df0a8c12d541f7bf385b1fb94d028846a /main.go | |
parent | f888a1c70aaa168e5956f911fd34b7a0a9bc8614 (diff) |
Improved reported error on invalid XDS_AGENT_URL
Specifically when AGENT_URL is set to SERVER_URL and consequently connection failed with "Failed to get device ID" error.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -328,15 +328,22 @@ func XdsConnInit(ctx *cli.Context) error { CsrfDisable: true, LogOut: Log.Out, LogPrefix: "XDSAGENT: ", - LogLevel: common.HTTPLogLevelWarning, + LogLevel: common.HTTPLogLevelDebug, } HTTPCli, err = common.HTTPNewClient(agentURL, conf) if err != nil { errmsg := err.Error() - if m, err := regexp.MatchString("Get http.?://", errmsg); m && err == nil { + m, err := regexp.MatchString("Get http.?://", errmsg) + if (m && err == nil) || strings.Contains(errmsg, "Failed to get device ID") { i := strings.LastIndex(errmsg, ":") - errmsg = "Cannot connection to " + agentURL + errmsg[i:] + newErr := "Cannot connection to " + agentURL + if i > 0 { + newErr += " (" + strings.TrimSpace(errmsg[i+1:]) + ")" + } else { + newErr += " (" + strings.TrimSpace(errmsg) + ")" + } + errmsg = newErr } return cli.NewExitError(errmsg, 1) } |