Skip to content

Commit 2e762ea

Browse files
chore: reduce error verbosity (#79)
Before & After: ![image](https://github.com/user-attachments/assets/6f05acb4-ff31-4163-a653-a16a569736e9) We always want to show the `localizedDescription`, and rarely anything else. These long errors make for a pretty poor UX. Logs are unchanged.
1 parent ea73a0a commit 2e762ea

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Coder Desktop/Coder Desktop/Views/LoginForm.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ enum LoginError: Error {
201201
case .invalidURL:
202202
"Invalid URL"
203203
case let .failedAuth(err):
204-
"Could not authenticate with Coder deployment:\n\(err.description)"
204+
"Could not authenticate with Coder deployment:\n\(err.localizedDescription)"
205205
}
206206
}
207207

Coder Desktop/CoderSDK/Client.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public enum ClientError: Error {
131131
case let .unexpectedResponse(data):
132132
"Unexpected or non HTTP response: \(data)"
133133
case let .encodeFailure(error):
134-
"Failed to encode body: \(error)"
134+
"Failed to encode body: \(error.localizedDescription)"
135135
}
136136
}
137137

Coder Desktop/VPN/Manager.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,17 @@ enum ManagerError: Error {
251251
var description: String {
252252
switch self {
253253
case let .download(err):
254-
"Download error: \(err)"
254+
"Download error: \(err.localizedDescription)"
255255
case let .tunnelSetup(err):
256-
"Tunnel setup error: \(err)"
256+
"Tunnel setup error: \(err.localizedDescription)"
257257
case let .handshake(err):
258-
"Handshake error: \(err)"
258+
"Handshake error: \(err.localizedDescription)"
259259
case let .validation(err):
260-
"Validation error: \(err)"
260+
"Validation error: \(err.localizedDescription)"
261261
case .incorrectResponse:
262262
"Received unexpected response over tunnel"
263263
case let .failedRPC(err):
264-
"Failed rpc: \(err)"
264+
"Failed rpc: \(err.localizedDescription)"
265265
case let .serverInfo(msg):
266266
msg
267267
case let .errorResponse(msg):
@@ -273,7 +273,7 @@ enum ManagerError: Error {
273273
case .permissionDenied:
274274
"Permission was not granted to execute the CoderVPN dylib"
275275
case let .tunnelFail(err):
276-
"Failed to communicate with dylib over tunnel: \(err)"
276+
"Failed to communicate with dylib over tunnel: \(err.localizedDescription)"
277277
}
278278
}
279279

Coder Desktop/VPN/TunnelHandle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ enum TunnelHandleError: Error {
7575

7676
var description: String {
7777
switch self {
78-
case let .pipe(err): "pipe error: \(err)"
78+
case let .pipe(err): "pipe error: \(err.localizedDescription)"
7979
case let .dylib(d): d
8080
case let .symbol(symbol, message): "\(symbol): \(message)"
8181
case let .openTunnel(error): "OpenTunnel: \(error.message)"

Coder Desktop/VPNLib/Download.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public func download(src: URL, dest: URL, urlSession: URLSession) async throws(D
116116
do {
117117
(tempURL, response) = try await urlSession.download(for: req)
118118
} catch {
119-
throw .networkError(error)
119+
throw .networkError(error, url: src.absoluteString)
120120
}
121121
defer {
122122
if FileManager.default.fileExists(atPath: tempURL.path) {
@@ -155,15 +155,15 @@ func etag(data: Data) -> String {
155155
public enum DownloadError: Error {
156156
case unexpectedStatusCode(Int)
157157
case invalidResponse
158-
case networkError(any Error)
158+
case networkError(any Error, url: String)
159159
case fileOpError(any Error)
160160

161161
public var description: String {
162162
switch self {
163163
case let .unexpectedStatusCode(code):
164164
"Unexpected HTTP status code: \(code)"
165-
case let .networkError(error):
166-
"Network error: \(error.localizedDescription)"
165+
case let .networkError(error, url):
166+
"Network error: \(url) - \(error.localizedDescription)"
167167
case let .fileOpError(error):
168168
"File operation error: \(error.localizedDescription)"
169169
case .invalidResponse:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy