Skip to content

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

Open
@weissi

Description

@weissi

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.)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions