changeset 601:d36027b41570 0.12

better error message
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 29 Sep 2015 01:34:20 -0600
parents b926e53910dd
children b33c7c1e45d0
files lucene/src/luan/modules/lucene/LuceneIndex.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
diff -r b926e53910dd -r d36027b41570 lucene/src/luan/modules/lucene/LuceneIndex.java
--- a/lucene/src/luan/modules/lucene/LuceneIndex.java	Mon Sep 28 00:32:27 2015 -0600
+++ b/lucene/src/luan/modules/lucene/LuceneIndex.java	Tue Sep 29 01:34:20 2015 -0600
@@ -142,7 +142,13 @@
 	public void save(LuanState luan,LuanTable doc) throws LuanException, IOException {
 		if( doc.get(luan,"type")==null )
 			throw new LuanException(luan,"missing 'type' field");
-		Long id = (Long)doc.get(luan,"id");
+		Object obj = doc.get(luan,"id");
+		Long id;
+		try {
+			id = (Long)obj;
+		} catch(ClassCastException e) {
+			throw new LuanException(luan,"id should be Long but is "+obj.getClass().getSimpleName());
+		}
 
 		boolean commit = !writeLock.isHeldByCurrentThread();
 		writeLock.lock();