- if (!closed) {
- yaz4jlib.ZOOM_connection_destroy(zoomConnection);
- zoomConnection = null;
- closed = true;
- }
- }
-
- private void checkErrorCodeAndThrow(int errorCode) throws ZoomException {
- String message;
-
- if (errorCode == yaz4jlibConstants.ZOOM_ERROR_NONE) {
- return;
- } else if (errorCode == yaz4jlib.ZOOM_ERROR_CONNECT) {
- message = String.format("Connection could not be made to %s:%d", host, port);
- throw new ConnectionUnavailableException(message);
- } else if (errorCode == yaz4jlib.ZOOM_ERROR_INVALID_QUERY) {
- message = String.format("The query requested is not valid or not supported");
- throw new InvalidQueryException(message);
- } else if (errorCode == yaz4jlib.ZOOM_ERROR_INIT) {
- message = String.format("Server %s:%d rejected our init request", host, port);
- throw new InitRejectedException(message);
- } else if (errorCode == yaz4jlib.ZOOM_ERROR_TIMEOUT) {
- message = String.format("Server %s:%d timed out handling our request", host, port);
- throw new ConnectionTimeoutException(message);
- } else if ((errorCode == yaz4jlib.ZOOM_ERROR_MEMORY) || (errorCode == yaz4jlib.ZOOM_ERROR_ENCODE) || (errorCode == yaz4jlib.ZOOM_ERROR_DECODE) || (errorCode == yaz4jlib.ZOOM_ERROR_CONNECTION_LOST) || (errorCode == yaz4jlib.ZOOM_ERROR_INTERNAL) || (errorCode == yaz4jlib.ZOOM_ERROR_UNSUPPORTED_PROTOCOL) || (errorCode == yaz4jlib.ZOOM_ERROR_UNSUPPORTED_QUERY)) {
- message = yaz4jlib.ZOOM_connection_errmsg(zoomConnection);
- throw new ZoomImplementationException("A fatal error occurred in Yaz: " + errorCode + " - " + message);
- } else {
- String errMsgBib1 = "Bib1Exception: Error Code = " + errorCode + " (" + Bib1Diagnostic.getError(errorCode) + ")";
- throw new Bib1Exception(errMsgBib1);
- }