swift-server / swift-server/async-http-client
AHC errors have bad `.localizedDescription` (always claims `error 1`)
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 1.1k
- Forks
- 156
- PR merge metrics
- No merged PRs in 30d
Description
I'm using a library that unfortunately does logger[metadataKey: "request.error"] = .string(error.localizedDescription) where the error is an error out of AHC. The result is that it always prints
request.error=The operation couldn’t be completed. (AsyncHTTPClient.HTTPClientError error 1.)
Note that error 1 is produced regardless of the actual error.
The source of the problem is this oddity in Swift/Foundation:
import Foundation
struct MyError: Error & CustomStringConvertible { var description: String { "hello" } }
print((MyError() as Error).localizedDescription)
// produces: "The operation couldn’t be completed. (MyError error 1.)"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing AsyncHTTPClient.HTTPClientError and its error-description behavior, then reproduce the reported localizedDescription output in Swift/Foundation. The fix is complete when AHC errors expose their actual error details instead of the generic “error 1” text; no test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100