Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AHC errors have bad .localizedDescription (always claims error 1) #797

Open
weissi opened this issue Dec 18, 2024 · 0 comments
Open

AHC errors have bad .localizedDescription (always claims error 1) #797

weissi opened this issue Dec 18, 2024 · 0 comments

Comments

@weissi
Copy link
Contributor

weissi commented Dec 18, 2024

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.)"
@weissi weissi changed the title AHC errors have bad .localizedDescription AHC errors have bad .localizedDescription (always claims error 1) Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant