Commit c16af387 authored by Geoff Simmons's avatar Geoff Simmons

Improve error messages derived from the dataplane API.

parent 29092b3c
...@@ -35,6 +35,7 @@ import ( ...@@ -35,6 +35,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/go-openapi/strfmt" "github.com/go-openapi/strfmt"
...@@ -108,7 +109,27 @@ type DataplaneError struct { ...@@ -108,7 +109,27 @@ type DataplaneError struct {
} }
func (err *DataplaneError) Error() string { func (err *DataplaneError) Error() string {
return *err.Err.Message var sb strings.Builder
sb.WriteString(http.StatusText(err.Status))
sb.WriteString(" (")
sb.WriteString(strconv.Itoa(err.Status))
sb.WriteString(") version=")
sb.WriteString(strconv.Itoa(err.Version))
if err.Err.Code != nil {
sb.WriteString(" models.Error.Code=")
sb.WriteString(strconv.Itoa(int(*err.Err.Code)))
}
for k, v := range err.Err.Error {
sb.WriteRune(' ')
sb.WriteString(k)
sb.WriteRune('=')
sb.WriteString(v)
}
if err.Err.Message != nil {
sb.WriteString(": ")
sb.WriteString(*err.Err.Message)
}
return sb.String()
} }
type DataplaneClient struct { type DataplaneClient struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment