summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-07 17:46:44 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-07 17:46:44 +0100
commit8eec65457e532c0e6a9721e3c6df9a6a9489d96f (patch)
tree220e086d5c3a13f64f08e733e0a9d599105e5de8
parent9a0c120497cfe3cfdca6dfd084e999b6ab915ce8 (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.
-rw-r--r--gdb-xds.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/gdb-xds.go b/gdb-xds.go
index d57817d..0e93b52 100644
--- a/gdb-xds.go
+++ b/gdb-xds.go
@@ -120,14 +120,22 @@ func (g *GdbXds) Init() (int, error) {
HeaderClientKeyName: "Xds-Agent-Sid",
CsrfDisable: true,
LogOut: g.log.Out,
- LogLevel: common.HTTPLogLevelWarning,
+ LogPrefix: "XDSAGENT: ",
+ LogLevel: common.HTTPLogLevelDebug,
}
c, err := common.HTTPNewClient(baseURL, 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 " + baseURL + errmsg[i:]
+ newErr := "Cannot connection to " + baseURL
+ if i > 0 {
+ newErr += " (" + strings.TrimSpace(errmsg[i+1:]) + ")"
+ } else {
+ newErr += " (" + strings.TrimSpace(errmsg) + ")"
+ }
+ errmsg = newErr
}
return int(syscallEBADE), fmt.Errorf(errmsg)
}