|
| 1 | +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +/// Errors thrown by the example's functions. |
| 5 | +enum TransferError: Error { |
| 6 | + /// The destination directory for a download is missing or inaccessible. |
| 7 | + case directoryError |
| 8 | + /// An error occurred while downloading a file from Amazon S3. |
| 9 | + case downloadError(_ message: String = "") |
| 10 | + /// An error occurred moving the file to its final destination. |
| 11 | + case fileMoveError |
| 12 | + /// An error occurred when completing a multi-part upload to Amazon S3. |
| 13 | + case multipartFinishError |
| 14 | + /// An error occurred when starting a multi-part upload to Amazon S3. |
| 15 | + case multipartStartError |
| 16 | + /// An error occurred while uploading a file to Amazon S3. |
| 17 | + case uploadError(_ message: String = "") |
| 18 | + /// An error occurred while reading the file's contents. |
| 19 | + case readError |
| 20 | + /// An error occurred while presigning the URL. |
| 21 | + case signingError |
| 22 | + /// An error occurred while writing the file's contents. |
| 23 | + case writeError |
| 24 | + |
| 25 | + var errorDescription: String? { |
| 26 | + switch self { |
| 27 | + case .directoryError: |
| 28 | + return "The destination directory could not be located or created" |
| 29 | + case .downloadError(message: let message): |
| 30 | + return "An error occurred attempting to download the file: \(message)" |
| 31 | + case .fileMoveError: |
| 32 | + return "The file couldn't be moved to the destination directory" |
| 33 | + case .multipartFinishError: |
| 34 | + return "An error occurred when completing a multi-part upload to Amazon S3." |
| 35 | + case .multipartStartError: |
| 36 | + return "An error occurred when starting a multi-part upload to Amazon S3." |
| 37 | + case .uploadError(message: let message): |
| 38 | + return "An error occurred attempting to upload the file: \(message)" |
| 39 | + case .readError: |
| 40 | + return "An error occurred while reading the file data" |
| 41 | + case .signingError: |
| 42 | + return "An error occurred while pre-signing the URL" |
| 43 | + case .writeError: |
| 44 | + return "An error occurred while writing the file data" |
| 45 | + } |
| 46 | + } |
| 47 | +} |
0 commit comments