X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/55aafbb07904ca24390dd47ea960eae7cb2b909a..2e74236fa27822addd856f194befc28382990ce0:/sdk/go/arvados/error.go diff --git a/sdk/go/arvados/error.go b/sdk/go/arvados/error.go index 29eebdbf72..5329a5146a 100644 --- a/sdk/go/arvados/error.go +++ b/sdk/go/arvados/error.go @@ -17,25 +17,29 @@ type TransactionError struct { URL url.URL StatusCode int Status string - errors []string + Errors []string } func (e TransactionError) Error() (s string) { - s = fmt.Sprintf("request failed: %s", e.URL) + s = fmt.Sprintf("request failed: %s", e.URL.String()) if e.Status != "" { s = s + ": " + e.Status } - if len(e.errors) > 0 { - s = s + ": " + strings.Join(e.errors, "; ") + if len(e.Errors) > 0 { + s = s + ": " + strings.Join(e.Errors, "; ") } return } +func (e TransactionError) HTTPStatus() int { + return e.StatusCode +} + func newTransactionError(req *http.Request, resp *http.Response, buf []byte) *TransactionError { var e TransactionError if json.Unmarshal(buf, &e) != nil { // No JSON-formatted error response - e.errors = nil + e.Errors = nil } e.Method = req.Method e.URL = *req.URL