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.