aboutsummaryrefslogtreecommitdiff
path: root/errors.go
diff options
context:
space:
mode:
authorStefan Majewsky <stefan.majewsky@sap.com>2022-10-28 16:06:40 +0200
committerStefan Majewsky <stefan.majewsky@sap.com>2022-10-28 16:06:40 +0200
commit90dd519a948d06738479c04d331f28dfab99315c (patch)
treed4a9914cb73be3dbe9438b012a08408d79bdb7c9 /errors.go
parentfd6e57b6239655722884a49a86be0f051cc32bde (diff)
parent5cf9b60d2ded95d29827389a1a5901f1068d4337 (diff)
downloadgo-schwift-90dd519a948d06738479c04d331f28dfab99315c.tar.gz
Merge remote-tracking branch 'SuperSandro2000:sha2'
Diffstat (limited to 'errors.go')
-rw-r--r--errors.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/errors.go b/errors.go
index 825e96a..bee0b9f 100644
--- a/errors.go
+++ b/errors.go
@@ -56,16 +56,16 @@ var (
ErrSegmentInvalid = errors.New("segment invalid or incompatible with large object strategy")
)
-//UnexpectedStatusCodeError is generated when a request to Swift does not yield
-//a response with the expected successful status code. The actual status code
-//can be checked with the Is() function; see documentation over there.
+// UnexpectedStatusCodeError is generated when a request to Swift does not yield
+// a response with the expected successful status code. The actual status code
+// can be checked with the Is() function; see documentation over there.
type UnexpectedStatusCodeError struct {
ExpectedStatusCodes []int
ActualResponse *http.Response
ResponseBody []byte
}
-//Error implements the builtin/error interface.
+// Error implements the builtin/error interface.
func (e UnexpectedStatusCodeError) Error() string {
codeStrs := make([]string, len(e.ExpectedStatusCodes))
for idx, code := range e.ExpectedStatusCodes {
@@ -81,15 +81,15 @@ func (e UnexpectedStatusCodeError) Error() string {
return msg
}
-//BulkObjectError is the error message for a single object in a bulk operation.
-//It is not generated individually, only as part of BulkError.
+// BulkObjectError is the error message for a single object in a bulk operation.
+// It is not generated individually, only as part of BulkError.
type BulkObjectError struct {
ContainerName string
ObjectName string
StatusCode int
}
-//Error implements the builtin/error interface.
+// Error implements the builtin/error interface.
func (e BulkObjectError) Error() string {
return fmt.Sprintf("%s/%s: %d %s",
e.ContainerName, e.ObjectName,
@@ -97,10 +97,10 @@ func (e BulkObjectError) Error() string {
)
}
-//BulkError is returned by Account.BulkUpload() when the archive was
-//uploaded and unpacked successfully, but some (or all) objects could not be
-//saved in Swift; and by Account.BulkDelete() when not all requested objects
-//could be deleted.
+// BulkError is returned by Account.BulkUpload() when the archive was
+// uploaded and unpacked successfully, but some (or all) objects could not be
+// saved in Swift; and by Account.BulkDelete() when not all requested objects
+// could be deleted.
type BulkError struct {
//StatusCode contains the overall HTTP status code of the operation.
StatusCode int
@@ -112,8 +112,8 @@ type BulkError struct {
ObjectErrors []BulkObjectError
}
-//Error implements the builtin/error interface. To fit into one line, it
-//condenses the ObjectErrors into a count.
+// Error implements the builtin/error interface. To fit into one line, it
+// condenses the ObjectErrors into a count.
func (e BulkError) Error() string {
result := fmt.Sprintf("%d %s", e.StatusCode, http.StatusText(e.StatusCode))
if e.OverallError != "" {
@@ -125,8 +125,8 @@ func (e BulkError) Error() string {
return result
}
-//Is checks if the given error is an UnexpectedStatusCodeError for that status
-//code. For example:
+// Is checks if the given error is an UnexpectedStatusCodeError for that status
+// code. For example:
//
// err := container.Delete(nil)
// if err != nil {
@@ -139,7 +139,7 @@ func (e BulkError) Error() string {
// }
// }
//
-//It is safe to pass a nil error, in which case Is() always returns false.
+// It is safe to pass a nil error, in which case Is() always returns false.
func Is(err error, code int) bool {
if e, ok := err.(UnexpectedStatusCodeError); ok {
return e.ActualResponse.StatusCode == code
@@ -147,14 +147,14 @@ func Is(err error, code int) bool {
return false
}
-//MalformedHeaderError is generated when a response from Swift contains a
-//malformed header.
+// MalformedHeaderError is generated when a response from Swift contains a
+// malformed header.
type MalformedHeaderError struct {
Key string
ParseError error
}
-//Error implements the builtin/error interface.
+// Error implements the builtin/error interface.
func (e MalformedHeaderError) Error() string {
return "Bad header " + e.Key + ": " + e.ParseError.Error()
}