Issue #439

Use localizedDescription

We need to provide NSLocalizedDescriptionKey inside user info dictionary, otherwise the outputt string may not be what we want.


A string containing the localized description of the error. The object in the user info dictionary for the key NSLocalizedDescriptionKey. If the user info dictionary doesn’t contain a value for NSLocalizedDescriptionKey, a default string is constructed from the domain and code.

let error = NSError(domain: "com.onmyway133.MyApp", code: 2, userInfo: [
    "status_code": 2,
    "status_message": "not enough power"

// "The operation couldn’t be completed. (com.onmyway133.MyApp error 2.)"


Retrieve the localized description for this error.

enum AppError: Error {
    case request
    case invalid

// "The operation couldn’t be completed. (MyApp.AppError error 0.)"

Use describing String

To have better control, we can have toString which prints closly to what we expect

extension Error {
    func toString() -> String {
        return String(describing: self)

// request

// Error Domain=com.onmyway133.MyApp Code=2 "(null)" UserInfo={status_message=not enough power, status_code=SwiftGRPC.StatusCode.powerRequired}