From 9e8ed9ef479ca2084d9e34edfda0a99be34dbdb5 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Thu, 8 Mar 2018 23:02:44 +0100 Subject: generalize BulkUploadError into BulkError For use in Account.BulkDelete(). --- errors.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'errors.go') 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)) -- cgit v1.2.3