@@ -229,14 +229,14 @@ enum StorageMultipartUpload {
229
229
case . parts( let uploadId, let uploadFile, let partSize, let parts) :
230
230
self = . paused( uploadId: uploadId, uploadFile: uploadFile, partSize: partSize, parts: parts)
231
231
default :
232
- throw Failure . invalidStateTransition ( reason: " Cannot pause from current state: \( self ) " )
232
+ throw Failure . invalidStateTransition ( reason: " Cannot pause upload: upload must be in progress " )
233
233
}
234
234
case . resuming:
235
235
switch self {
236
236
case . paused( let uploadId, let uploadFile, let partSize, let parts) :
237
237
self = . parts( uploadId: uploadId, uploadFile: uploadFile, partSize: partSize, parts: parts)
238
238
default :
239
- throw Failure . invalidStateTransition ( reason: " Cannot resume from current state: \( self ) " )
239
+ throw Failure . invalidStateTransition ( reason: " Cannot resume upload: upload must be paused " )
240
240
}
241
241
break
242
242
case . completing( let taskIdentifier) :
@@ -246,20 +246,20 @@ enum StorageMultipartUpload {
246
246
case . parts:
247
247
self = . completed( uploadId: uploadId)
248
248
default :
249
- throw Failure . invalidStateTransition ( reason: " Cannot complete from current state: \( self ) " )
249
+ throw Failure . invalidStateTransition ( reason: " Cannot complete upload: upload must be in progress " )
250
250
}
251
251
case . aborting( let error) :
252
252
if let uploadId = uploadId {
253
253
self = . aborting( uploadId: uploadId, error: error)
254
254
} else {
255
- throw Failure . invalidStateTransition ( reason: " Cannot abort from current state: \( self ) " )
255
+ throw Failure . invalidStateTransition ( reason: " Cannot abort upload: no upload ID available " )
256
256
}
257
257
case . aborted( let uploadId, let error) :
258
258
switch self {
259
259
case . created, . parts, . aborting:
260
260
self = . aborted( uploadId: uploadId, error: error)
261
261
default :
262
- throw Failure . invalidStateTransition ( reason: " Cannot abort from current state: \( self ) " )
262
+ throw Failure . invalidStateTransition ( reason: " Cannot abort upload: upload must be in progress or created " )
263
263
}
264
264
case . failed( let uploadId, let error) :
265
265
switch self {
@@ -268,7 +268,7 @@ enum StorageMultipartUpload {
268
268
case . parts( _, _, _, let parts) :
269
269
self = . failed( uploadId: uploadId, parts: parts, error: error)
270
270
default :
271
- throw Failure . invalidStateTransition ( reason: " Cannot fail from current state: \( self ) " )
271
+ throw Failure . invalidStateTransition ( reason: " Cannot fail upload: invalid state for failure " )
272
272
}
273
273
}
274
274
}
@@ -277,7 +277,7 @@ enum StorageMultipartUpload {
277
277
mutating func transition( uploadPartEvent: StorageUploadPartEvent ) throws {
278
278
guard !isAborting, !isAborted else { return }
279
279
guard case . parts( let uploadId, let uploadFile, let partSize, var parts) = self else {
280
- throw Failure . invalidStateTransition ( reason: " Parts are required for this transition: \( uploadPartEvent ) " )
280
+ throw Failure . invalidStateTransition ( reason: " Cannot process part event: upload must be in progress " )
281
281
}
282
282
283
283
let partNumber = uploadPartEvent. number
@@ -297,12 +297,12 @@ enum StorageMultipartUpload {
297
297
parts [ index] = . inProgress( bytes: part. bytes, bytesTransferred: 0 , taskIdentifier: taskIdentifier)
298
298
case . progressUpdated( _, let bytesTransferred, _) :
299
299
guard case . inProgress( let bytes, _, let taskIdentifier) = part else {
300
- throw Failure . invalidStateTransition ( reason: " Part cannot update progress in current state: \( self ) " )
300
+ throw Failure . invalidStateTransition ( reason: " Cannot update progress: part must be in progress " )
301
301
}
302
302
parts [ index] = . inProgress( bytes: bytes, bytesTransferred: bytesTransferred, taskIdentifier: taskIdentifier)
303
303
case . completed( _, let eTag, _) :
304
304
guard case . inProgress( let bytes, _, _) = part else {
305
- throw Failure . invalidStateTransition ( reason: " Part cannot be completed in current state: \( self ) " )
305
+ throw Failure . invalidStateTransition ( reason: " Cannot complete part: part must be in progress " )
306
306
}
307
307
parts [ index] = StorageUploadPart . completed ( bytes: bytes, eTag: eTag)
308
308
case . failed:
0 commit comments