Skip to content

Commit 2c7ca5b

Browse files
committed
some cleanup
1 parent 9895e8b commit 2c7ca5b

File tree

4 files changed

+64
-5
lines changed

4 files changed

+64
-5
lines changed

Sources/TUSKit/TUSAPI.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ public enum TUSAPIError: Error {
1515
case couldNotRetrieveOffset
1616
case couldNotRetrieveLocation
1717
case failedRequest(HTTPURLResponse)
18+
19+
public var localizedDescription: String {
20+
switch self {
21+
case .underlyingError(let error):
22+
return error.localizedDescription
23+
case .couldNotFetchStatus:
24+
return "Could not fetch status from server."
25+
case .couldNotFetchServerInfo:
26+
return "Could not fetch server info."
27+
case .couldNotRetrieveOffset:
28+
return "Could not retrieve offset from response."
29+
case .couldNotRetrieveLocation:
30+
return "Could not retrieve location from response."
31+
case .failedRequest(let response):
32+
return "Failed request with status code \(response.statusCode)."
33+
}
34+
}
1835
}
1936

2037
/// The status of an upload.

Sources/TUSKit/TUSClientError.swift

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,50 @@ public enum TUSClientError: Error {
1919
case couldnotRemoveFinishedUploads(underlyingError: Error)
2020
case receivedUnexpectedOffset
2121
case missingRemoteDestination
22-
case emptyUploadRange
2322
case rangeLargerThanFile
2423
case taskCancelled
24+
case emptyUploadRange
25+
26+
public var localizedDescription: String {
27+
switch self {
28+
case .couldNotCopyFile(let underlyingError):
29+
return "Could not copy file: \(underlyingError.localizedDescription)"
30+
case .couldNotStoreFile(let underlyingError):
31+
return "Could not store file: \(underlyingError.localizedDescription)"
32+
case .fileSizeUnknown:
33+
return "The file size is unknown."
34+
case .couldNotLoadData(let underlyingError):
35+
return "Could not load data: \(underlyingError.localizedDescription)"
36+
case .couldNotStoreFileMetadata(let underlyingError):
37+
return "Could not store file metadata: \(underlyingError.localizedDescription)"
38+
case .couldNotCreateFileOnServer:
39+
return "Could not create file on server."
40+
case .couldNotUploadFile(let underlyingError):
41+
return "Could not upload file: \(underlyingError.localizedDescription)"
42+
case .couldNotGetFileStatus:
43+
return "Could not get file status."
44+
case .fileSizeMismatchWithServer:
45+
return "File size mismatch with server."
46+
case .couldNotDeleteFile(let underlyingError):
47+
return "Could not delete file: \(underlyingError.localizedDescription)"
48+
case .uploadIsAlreadyFinished:
49+
return "The upload is already finished."
50+
case .couldNotRetryUpload:
51+
return "Could not retry upload."
52+
case .couldNotResumeUpload:
53+
return "Could not resume upload."
54+
case .couldnotRemoveFinishedUploads(let underlyingError):
55+
return "Could not remove finished uploads: \(underlyingError.localizedDescription)"
56+
case .receivedUnexpectedOffset:
57+
return "Received unexpected offset."
58+
case .missingRemoteDestination:
59+
return "Missing remote destination for upload."
60+
case .emptyUploadRange:
61+
return "The upload range is empty."
62+
case .rangeLargerThanFile:
63+
return "The upload range is larger than the file size."
64+
case .taskCancelled:
65+
return "The task was cancelled."
66+
}
67+
}
2568
}

TUSKitExample/TUSKitExample/Screens/Upload/RowViews/ProgressRowView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ struct ProgressRowView: View {
9696
UploadActionImage(icon: .pause)
9797
}
9898

99-
// DestructiveButton(title: showTitle ? "Remove" : nil) {
100-
// tusWrapper.clearUpload(id: key)
101-
// }
99+
DestructiveButton(title: showTitle ? "Remove" : nil) {
100+
tusWrapper.clearUpload(id: key)
101+
}
102102
}
103103
}

TUSKitExample/TUSKitExample/Screens/Upload/UploadsListView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ extension UploadsListView {
132132
case .uploaded(let url):
133133
UploadedRowView(key: idx.key, url: url)
134134
case .failed(let error):
135-
let _ = print(error)
136135
FailedRowView(key: idx.key, error: error)
137136
}
138137
}

0 commit comments

Comments
 (0)