-
Notifications
You must be signed in to change notification settings - Fork 148
Closed
apple/swift-openapi-runtime
#143Labels
area/runtimeAffects: the runtime library.Affects: the runtime library.good first issueGood for newcomersGood for newcomerskind/bugFeature doesn't work as expected.Feature doesn't work as expected.
Description
Description
In pure Swift programs it's quite important to not call .localizedDescription on random error types -- unless they are verified to be proper NSErrors. Unfortunately, ClientError's description does just that.
Consider this Swift program
import Foundation
public enum SomeSwiftError: Error {
case aFailed
case bFailed
}
do {
throw SomeSwiftError.bFailed
} catch {
print("correct (just print)", error)
print("incorrect (localizedDescription)", error.localizedDescription)
}
the output is
$ swiftc bad.swift && ./bad
correct (just print) bFailed
incorrect (localizedDescription) The operation couldn’t be completed. (bad.SomeSwiftError error 1.)
See how localizedDescription just prints The operation couldn’t be completed. (TYPE error 1.). Even the error number is statically just 1.
Bottom line: If I do print(errorFromOpenAPIRuntime) I always get The operation couldn’t be completed. (AsyncHTTPClientError error 1.) with no further information.
Underlying bug is swiftlang/swift#58724
Reproduction
n/a
Package version(s)
latest
Expected behavior
prints the correct error, crucially it must never call localizedDescription.
Environment
all
Additional information
No response
Metadata
Metadata
Assignees
Labels
area/runtimeAffects: the runtime library.Affects: the runtime library.good first issueGood for newcomersGood for newcomerskind/bugFeature doesn't work as expected.Feature doesn't work as expected.