1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
15 type TransactionError struct {
23 func (e TransactionError) Error() (s string) {
24 s = fmt.Sprintf("request failed: %s", e.URL.String())
26 s = s + ": " + e.Status
28 if len(e.Errors) > 0 {
29 s = s + ": " + strings.Join(e.Errors, "; ")
34 func (e TransactionError) HTTPStatus() int {
38 func newTransactionError(req *http.Request, resp *http.Response, buf []byte) *TransactionError {
39 var e TransactionError
40 if json.Unmarshal(buf, &e) != nil {
41 // No JSON-formatted error response
47 e.Status = resp.Status
48 e.StatusCode = resp.StatusCode