 	
 }
 
-public enum ConnectionErrorCode: Int {
+public enum ConnectionErrorType: Int {
 	case appNotFound = 10
 	case authFailed = 11
 	case interfaceNotFound = 12

	case methodNotFound = 14
	case notSerever = 15
	case internalError = 16
}


public class ConnectionError: Error, LocalizedError {
	
	public typealias Code = Int
	public typealias ErrorType = ConnectionErrorType
	
	public init(type: ErrorType, description: String? = nil) {
		self.type = type
		self.code = type.rawValue
		self.errorDescription = description ?? ConnectionError.defaultMessages[type.rawValue]
	}
	
	public init(code: Int, description: String? = nil) {
		self.code = code
		self.type = ErrorType(rawValue: code)
		self.errorDescription = description ?? ConnectionError.defaultMessages[code]
	}
	
	public var code: Code
	public var type: ErrorType?
	public var errorDescription: String?
	
	internal var asObject: Any {
		return ["code": code, "message": localizedDescription]
	}
	
	internal static func withObject(_ object: Any?) -> ConnectionError? {
		guard let data = object  as? [Any],
		      let code = data[0] as? Int else {
			return nil
		}
		return ConnectionError(code: code, description: data[safe: 1] as? String)
	}
	
	// MARK: -
