private void CheckErrorCodeAndThrow(int errorCode) { string message; switch (errorCode) { case Yaz.ZoomErrorNone: break; case Yaz.ZoomErrorConnect: message = $"Connection could not be made to {_host}:{_port}"; throw new Exception(message); case Yaz.ZoomErrorInvalidQuery: message = "The query requested is not valid or not supported"; throw new Exception(message); case Yaz.ZoomErrorInit: message = string.Format("Server {0}:{1} rejected our init request", _host, _port); throw new Exception(message); case Yaz.ZoomErrorTimeout: message = string.Format("Server {0}:{1} timed out handling our request", _host, _port); throw new Exception(message); case Yaz.ZoomErrorMemory: case Yaz.ZoomErrorEncode: case Yaz.ZoomErrorDecode: case Yaz.ZoomErrorConnectionLost: case Yaz.ZoomErrorInternal: case Yaz.ZoomErrorUnsupportedProtocol: case Yaz.ZoomErrorUnsupportedQuery: message = Yaz.ZOOM_connection_errmsg(ZConnection); throw new Exception("A fatal error occurred in Yaz: " + errorCode + " - " + message); default: throw new Exception("未经处理的异常"); } }