From 05b17f92714ac8ad716bb379eea13a2b4ed4ce4e Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Mon, 16 Nov 2015 09:12:23 -0800 Subject: [PATCH 1/2] Adding details in the throw exception on a missing field. --- .../main/java/com/google/gson/internal/bind/TypeAdapters.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java b/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java index d284dd5b..c72c0d9a 100644 --- a/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java +++ b/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java @@ -796,7 +796,7 @@ public final class TypeAdapters { constantToName.put(constant, name); } } catch (NoSuchFieldException e) { - throw new AssertionError(); + throw new AssertionError("Missing field in " + classOfT.getName(), e); } } @Override public T read(JsonReader in) throws IOException { From c935f89b23c69e7c9d6d98df87f81635b3eb3700 Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Mon, 16 Nov 2015 09:16:23 -0800 Subject: [PATCH 2/2] Added the cause to Assertions --- gson/src/main/java/com/google/gson/internal/Excluder.java | 2 +- .../google/gson/internal/bind/ReflectiveTypeAdapterFactory.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gson/src/main/java/com/google/gson/internal/Excluder.java b/gson/src/main/java/com/google/gson/internal/Excluder.java index 1c71e3e7..bef79040 100644 --- a/gson/src/main/java/com/google/gson/internal/Excluder.java +++ b/gson/src/main/java/com/google/gson/internal/Excluder.java @@ -62,7 +62,7 @@ public final class Excluder implements TypeAdapterFactory, Cloneable { try { return (Excluder) super.clone(); } catch (CloneNotSupportedException e) { - throw new AssertionError(); + throw new AssertionError(e); } } diff --git a/gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java b/gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java index b954b017..960153aa 100644 --- a/gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java +++ b/gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java @@ -241,7 +241,7 @@ public final class ReflectiveTypeAdapterFactory implements TypeAdapterFactory { } } } catch (IllegalAccessException e) { - throw new AssertionError(); + throw new AssertionError(e); } out.endObject(); }