Merge branch '19109-upload-secondary' refs #19109
[arvados.git] / sdk / go / arvados / error.go
index 773a2e6f9c7d787406511f85a6a5585596153738..5329a5146ad75e616446be87c6755a61176d7b7f 100644 (file)
@@ -17,7 +17,7 @@ type TransactionError struct {
        URL        url.URL
        StatusCode int
        Status     string
-       errors     []string
+       Errors     []string
 }
 
 func (e TransactionError) Error() (s string) {
@@ -25,17 +25,21 @@ func (e TransactionError) Error() (s 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