// avoid the whole switch error type set description pattern we were using before (unless custom actions need to be attached or something) // see: https://stackoverflow.com/questions/39176196/how-to-provide-a-localized-description-with-an-error-type-in-swift import Foundation public enum customError:Error{ case NONETWORK case INVALIDJSON case UNEXPECTEDRESPONSE case INVALIDCREDENTIALS case Other(String?) } extension customError: LocalizedError { public var errorDescription: String? { switch self { case .NONETWORK: return NSLocalizedString("No hay conexión al servidor.", comment: "Sin conectividad") case .INVALIDJSON, .UNEXPECTEDRESPONSE: return NSLocalizedString("Respuesta del servidor invalida.", comment: "El servidor ha retornado una respuesta invalida.") case .INVALIDCREDENTIALS: return NSLocalizedString("El usuario o contraseña son incorrectos", comment: "Autorización Invalida") case .Other(let s): return s! } } }