From d9d57d02b27f6e4dbf4eaee406ca5e34351cac8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Westk=C3=A4mper?= Date: Mon, 30 Mar 2009 07:58:33 +0000 Subject: [PATCH] --- .../mysema/query/collections/AbstractColQuery.java | 4 ++-- .../query/collections/eval/JaninoEvaluator.java | 8 ++++++-- .../collections/iterators/FilteringMultiIterator.java | 2 +- .../main/java/com/mysema/query/grammar/JavaOps.java | 3 +-- .../com/mysema/query/collections/ColQueryTest.java | 11 ++++++++++- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/querydsl-collections/src/main/java/com/mysema/query/collections/AbstractColQuery.java b/querydsl-collections/src/main/java/com/mysema/query/collections/AbstractColQuery.java index 9f3ab2272..0fb8de2b1 100644 --- a/querydsl-collections/src/main/java/com/mysema/query/collections/AbstractColQuery.java +++ b/querydsl-collections/src/main/java/com/mysema/query/collections/AbstractColQuery.java @@ -129,7 +129,7 @@ public class AbstractColQuery> impleme try { return query.count(); } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage(), e); } } @@ -427,7 +427,7 @@ public class AbstractColQuery> impleme try { return createIterator(projection); } catch (Exception e) { - throw new RuntimeException("error", e); + throw new RuntimeException(e.getMessage(), e); } } diff --git a/querydsl-collections/src/main/java/com/mysema/query/collections/eval/JaninoEvaluator.java b/querydsl-collections/src/main/java/com/mysema/query/collections/eval/JaninoEvaluator.java index cadffd34d..398d6bbee 100644 --- a/querydsl-collections/src/main/java/com/mysema/query/collections/eval/JaninoEvaluator.java +++ b/querydsl-collections/src/main/java/com/mysema/query/collections/eval/JaninoEvaluator.java @@ -33,7 +33,7 @@ public class JaninoEvaluator implements Evaluator{ Class type = expr.getType() != null ? expr.getType() : Object.class; ev = new JavaSerializer(ops).handle(expr).createExpressionEvaluator(sources, type); } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage(), e); } } @@ -41,7 +41,11 @@ public class JaninoEvaluator implements Evaluator{ try { return (T)ev.evaluate(args); } catch (InvocationTargetException e) { - throw new RuntimeException(e); + if (e.getCause() instanceof NullPointerException){ + throw new IllegalArgumentException("null path in expression"); + }else{ + throw new RuntimeException(e.getMessage(), e); + } } } diff --git a/querydsl-collections/src/main/java/com/mysema/query/collections/iterators/FilteringMultiIterator.java b/querydsl-collections/src/main/java/com/mysema/query/collections/iterators/FilteringMultiIterator.java index 5ca9749a0..1a9e90216 100644 --- a/querydsl-collections/src/main/java/com/mysema/query/collections/iterators/FilteringMultiIterator.java +++ b/querydsl-collections/src/main/java/com/mysema/query/collections/iterators/FilteringMultiIterator.java @@ -112,7 +112,7 @@ public class FilteringMultiIterator extends MultiIterator implements IteratorSou } catch (Exception e) { String error = "Caught " + e.getClass().getName(); logger.error(error, e); - throw new RuntimeException(error, e); + throw new RuntimeException(e.getMessage(), e); } } return this; diff --git a/querydsl-collections/src/main/java/com/mysema/query/grammar/JavaOps.java b/querydsl-collections/src/main/java/com/mysema/query/grammar/JavaOps.java index a6e524f35..d79fac7e4 100644 --- a/querydsl-collections/src/main/java/com/mysema/query/grammar/JavaOps.java +++ b/querydsl-collections/src/main/java/com/mysema/query/grammar/JavaOps.java @@ -73,8 +73,7 @@ public class JavaOps extends OperationPatterns { add(op, "Math."+getPattern(op)); } } catch (Exception e) { - String error = "Caught " + e.getClass().getName(); - throw new RuntimeException(error, e); + throw new RuntimeException(e.getMessage(), e); } add(Ops.OpMath.MOD, "%s %% %s"); diff --git a/querydsl-collections/src/test/java/com/mysema/query/collections/ColQueryTest.java b/querydsl-collections/src/test/java/com/mysema/query/collections/ColQueryTest.java index 4cb2c7709..f0d58c53d 100644 --- a/querydsl-collections/src/test/java/com/mysema/query/collections/ColQueryTest.java +++ b/querydsl-collections/src/test/java/com/mysema/query/collections/ColQueryTest.java @@ -171,7 +171,16 @@ public class ColQueryTest extends AbstractQueryTest{ assertNotNull($(c.getKittensByName())); assertNotNull($(c.getKittensByName().get("Kitty"))); from(c,cats) - .where($(c.getKittensByName().get("Kitty")).isnotnull()).list(cat); + .where($(c.getKittensByName().get("Kitty")).isnotnull()).list(cat); + + // 11 + try{ + from(cat,cats).where(cat.mate.alive).list(cat); + fail("expected RuntimeException"); + }catch(RuntimeException e){ + assertEquals("null path in expression", e.getMessage()); + } + } @Test