From 8c7413fbaf0870975229e8e101f79096b5dfe6f0 Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Wed, 3 Apr 2013 15:12:34 +0200 Subject: [PATCH] Fix error handling in ResultSet#getRecords A patch from Sergey Dostovalov, with minor modification. --- src/main/java/org/yaz4j/Connection.java | 10 ++++++++++ src/main/java/org/yaz4j/ResultSet.java | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/org/yaz4j/Connection.java b/src/main/java/org/yaz4j/Connection.java index a47ad3a..4accb99 100644 --- a/src/main/java/org/yaz4j/Connection.java +++ b/src/main/java/org/yaz4j/Connection.java @@ -200,6 +200,16 @@ public class Connection { yaz4jlib.ZOOM_connection_close(zoomConnection); closed = true; } + + /** + * Return exception type from current connection + * + * @return null if no error + */ + ZoomException getZoomException() { + ZoomException err = ExceptionUtil.getError(zoomConnection, host, port); + return err; + } /** * Write option with a given name. diff --git a/src/main/java/org/yaz4j/ResultSet.java b/src/main/java/org/yaz4j/ResultSet.java index 1949507..b2fd119 100644 --- a/src/main/java/org/yaz4j/ResultSet.java +++ b/src/main/java/org/yaz4j/ResultSet.java @@ -94,6 +94,10 @@ public class ResultSet implements Iterable { List out = new ArrayList(count); SWIGTYPE_p_p_ZOOM_record_p recs = yaz4jlib.new_zoomRecordArray(count); yaz4jlib.ZOOM_resultset_records(resultSet, recs, start, count); + ZoomException err = this.conn.getZoomException(); + if (err != null) { + throw err; + } for (int i = 0; i < count; i++) { SWIGTYPE_p_ZOOM_record_p record = yaz4jlib.zoomRecordArray_getitem(recs, i); -- 1.7.10.4