mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Add exception cause for method adapter creation.
This commit is contained in:
@@ -53,7 +53,7 @@ final class AdapterMethodsFactory implements JsonAdapter.Factory {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
String missingAnnotation = toAdapter == null ? "@ToJson" : "@FromJson";
|
String missingAnnotation = toAdapter == null ? "@ToJson" : "@FromJson";
|
||||||
throw new IllegalArgumentException("No " + missingAnnotation + " adapter for "
|
throw new IllegalArgumentException("No " + missingAnnotation + " adapter for "
|
||||||
+ typeAnnotatedWithAnnotations(type, annotations));
|
+ typeAnnotatedWithAnnotations(type, annotations), e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
delegate = null;
|
delegate = null;
|
||||||
|
@@ -463,6 +463,9 @@ public final class AdapterMethodsTest {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
assertThat(e).hasMessage("No @FromJson adapter for interface "
|
assertThat(e).hasMessage("No @FromJson adapter for interface "
|
||||||
+ "com.squareup.moshi.AdapterMethodsTest$Shape (with no annotations)");
|
+ "com.squareup.moshi.AdapterMethodsTest$Shape (with no annotations)");
|
||||||
|
assertThat(e).hasCauseExactlyInstanceOf(IllegalArgumentException.class);
|
||||||
|
assertThat(e.getCause()).hasMessage("No next JsonAdapter for interface "
|
||||||
|
+ "com.squareup.moshi.AdapterMethodsTest$Shape (with no annotations)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,6 +485,9 @@ public final class AdapterMethodsTest {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
assertThat(e).hasMessage("No @ToJson adapter for interface "
|
assertThat(e).hasMessage("No @ToJson adapter for interface "
|
||||||
+ "com.squareup.moshi.AdapterMethodsTest$Shape (with no annotations)");
|
+ "com.squareup.moshi.AdapterMethodsTest$Shape (with no annotations)");
|
||||||
|
assertThat(e).hasCauseExactlyInstanceOf(IllegalArgumentException.class);
|
||||||
|
assertThat(e.getCause()).hasMessage("No next JsonAdapter for interface "
|
||||||
|
+ "com.squareup.moshi.AdapterMethodsTest$Shape (with no annotations)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -334,6 +334,9 @@ public final class JsonQualifiersTest {
|
|||||||
} catch (IllegalArgumentException expected) {
|
} catch (IllegalArgumentException expected) {
|
||||||
assertThat(expected).hasMessage("No @FromJson adapter for class java.lang.String "
|
assertThat(expected).hasMessage("No @FromJson adapter for class java.lang.String "
|
||||||
+ "annotated [@com.squareup.moshi.JsonQualifiersTest$FooPrefix()]");
|
+ "annotated [@com.squareup.moshi.JsonQualifiersTest$FooPrefix()]");
|
||||||
|
assertThat(expected).hasCauseExactlyInstanceOf(IllegalArgumentException.class);
|
||||||
|
assertThat(expected.getCause()).hasMessage("No next JsonAdapter for class "
|
||||||
|
+ "java.lang.String annotated [@com.squareup.moshi.JsonQualifiersTest$FooPrefix()]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,6 +358,9 @@ public final class JsonQualifiersTest {
|
|||||||
} catch (IllegalArgumentException expected) {
|
} catch (IllegalArgumentException expected) {
|
||||||
assertThat(expected).hasMessage("No @ToJson adapter for class java.lang.String "
|
assertThat(expected).hasMessage("No @ToJson adapter for class java.lang.String "
|
||||||
+ "annotated [@com.squareup.moshi.JsonQualifiersTest$FooPrefix()]");
|
+ "annotated [@com.squareup.moshi.JsonQualifiersTest$FooPrefix()]");
|
||||||
|
assertThat(expected).hasCauseExactlyInstanceOf(IllegalArgumentException.class);
|
||||||
|
assertThat(expected.getCause()).hasMessage("No next JsonAdapter for class "
|
||||||
|
+ "java.lang.String annotated [@com.squareup.moshi.JsonQualifiersTest$FooPrefix()]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user