From 290fb69a5093ce13acad3552e95ce536b6318f28 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Sat, 22 Oct 2011 20:22:47 +0000 Subject: [PATCH] Provide more diagnostics when a constructor fails. --- .../com/google/gson/internal/ConstructorConstructor.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java b/gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java index ef7ae630..971a0b8b 100644 --- a/gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java +++ b/gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java @@ -91,11 +91,12 @@ public final class ConstructorConstructor { return (T) constructor.newInstance(args); } catch (InstantiationException e) { // TODO: JsonParseException ? - throw new RuntimeException(e); + throw new RuntimeException("Failed to invoke " + constructor + " with no args", e); } catch (InvocationTargetException e) { // TODO: don't wrap if cause is unchecked! // TODO: JsonParseException ? - throw new RuntimeException(e.getTargetException()); + throw new RuntimeException("Failed to invoke " + constructor + " with no args", + e.getTargetException()); } catch (IllegalAccessException e) { throw new AssertionError(e); }