It seems that the Error
type in Swift provides only one property, localizedDescription
. My app will be running on machines set to other languages than English. I would like to write error reports (for my perusal, not the user’s) in English: I need the non-localized description of the error. How can I get it?
How to access non-localized description of Error?
Asked Answered
What I did to solve this issue is create a string using the error's domain and code. Something like:
extension Error {
var logString: String {
return (self as NSError).code + ":" + (self as NSError).domain
}
}
© 2022 - 2024 — McMap. All rights reserved.
CustomStringConvertible
orCustomDebugStringConvertible
– Char