Mercurial Hosting > luan
diff lucene/src/luan/modules/lucene/LuceneIndex.java @ 601:d36027b41570 0.12
better error message
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Sep 2015 01:34:20 -0600 |
parents | 50540f0813e2 |
children | e54c1646eed0 |
line wrap: on
line diff
--- 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();