Fix error handling in ResultSet#getRecords
authorJakub Skoczen <jakub@indexdata.dk>
Wed, 3 Apr 2013 13:12:34 +0000 (15:12 +0200)
committerJakub Skoczen <jakub@indexdata.dk>
Wed, 3 Apr 2013 13:12:34 +0000 (15:12 +0200)
A patch from Sergey Dostovalov, with minor modification.

src/main/java/org/yaz4j/Connection.java
src/main/java/org/yaz4j/ResultSet.java

index a47ad3a..4accb99 100644 (file)
@@ -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.
index 1949507..b2fd119 100644 (file)
@@ -94,6 +94,10 @@ public class ResultSet implements Iterable<Record> {
     List<Record> out = new ArrayList<Record>(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);