Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access non-localized description of Error?

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?

like image 316
Philippe-André Lorin Avatar asked Dec 20 '25 09:12

Philippe-André Lorin


1 Answers

enum SomeError: String, Error, CustomDebugStringConvertible {
var debugDescription: String {
    self.rawValue
}

case error1
case error2

}

Then just

print(SomeError.error1.debugDescription)
like image 104
user20325868 Avatar answered Dec 22 '25 00:12

user20325868



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!