doxuto
(Doxuto)
1
Hi everyone,
I declare errorDescription asynchronous property.
That's OK when I call await errorDescription
But got "The operation couldn’t be completed" when accessing localizedDescription
As nserror bridging
The runtime would need to register a user info value provider for each error type the first time it is bridged into NSError , supplying the domain and the following user info value provider function
That’s a bug?
enum MyError: LocalizedError {
case unknownError
var errorDescription: String {
get async {
switch self {
case .unknownError:
try! await Task.sleep(nanoseconds: 1_000_000)
return "Custom unknown error"
}
}
}
}
Task {
print(await MyError.unknownError.errorDescription) //Custom unknown error
}
print(MyError.unknownError.localizedDescription) //The operation couldn’t be completed.
A protocol conformance cannot add async or throws, but it can remove them.
It can also remove ? from a failable initializer, but not from a method/property/subscript.
Your errorDescription doesn't match the protocol requirement, so I think your conformance is using a default implementation (which returns nil).