aboutsummaryrefslogtreecommitdiff
path: root/errors.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2018-03-08 23:02:44 +0100
committerStefan Majewsky <majewsky@gmx.net>2018-03-08 23:02:44 +0100
commit9e8ed9ef479ca2084d9e34edfda0a99be34dbdb5 (patch)
treea07542caa4dfc3ccd2fe058f27ccadf3a459e91a /errors.go
parent0a9bb149419c4df0be820f2cb72c8cc7e3332c68 (diff)
downloadgo-schwift-9e8ed9ef479ca2084d9e34edfda0a99be34dbdb5.tar.gz
generalize BulkUploadError into BulkError
For use in Account.BulkDelete().
Diffstat (limited to 'errors.go')
-rw-r--r--errors.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/errors.go b/errors.go
index 3ce7cd0..1eab131 100644
--- a/errors.go
+++ b/errors.go
@@ -66,7 +66,7 @@ func (e UnexpectedStatusCodeError) Error() string {
}
//BulkObjectError is the error message for a single object in a bulk operation.
-//It is not generated individually, only as part of BulkUploadError and BulkDeleteError.
+//It is not generated individually, only as part of BulkError.
type BulkObjectError struct {
ContainerName string
ObjectName string
@@ -81,27 +81,27 @@ func (e BulkObjectError) Error() string {
)
}
-//BulkUploadError is returned by Account.BulkUpload() when the archive was
-//uploaded and unpacked successfully, but some (or all) files could not be
-//saved in Swift.
-type BulkUploadError struct {
+//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
- //ArchiveError contains the error that occurred while unpacking the archive,
- //or if the archive as a whole was not acceptable. If may be empty if no
- //error occurred at this point.
- ArchiveError string
- //ObjectErrors contains errors that occurred while trying to save an
- //individual file from the archive. It may be empty.
+ //OverallError contains the fatal error that aborted the bulk operation, or a
+ //summary of which recoverable errors were encountered. It may be empty.
+ OverallError string
+ //ObjectErrors contains errors that occurred while working on individual
+ //objects. It may be empty if no such errors occurred.
ObjectErrors []BulkObjectError
}
//Error implements the builtin/error interface. To fit into one line, it
//condenses the ObjectErrors into a count.
-func (e BulkUploadError) Error() string {
+func (e BulkError) Error() string {
result := fmt.Sprintf("%d %s", e.StatusCode, http.StatusText(e.StatusCode))
- if e.ArchiveError != "" {
- result += ": " + e.ArchiveError
+ if e.OverallError != "" {
+ result += ": " + e.OverallError
}
if len(e.ObjectErrors) > 0 {
result += fmt.Sprintf(" (+%d object errors)", len(e.ObjectErrors))