From: Jakub Skoczen Date: Wed, 3 Apr 2013 13:12:34 +0000 (+0200) Subject: Fix error handling in ResultSet#getRecords X-Git-Tag: v1.3~7 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=8c7413fbaf0870975229e8e101f79096b5dfe6f0;p=yaz4j-moved-to-github.git Fix error handling in ResultSet#getRecords A patch from Sergey Dostovalov, with minor modification. --- 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);