mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Merge pull request #659 from square/eric.exception-cause
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) {
|
||||
String missingAnnotation = toAdapter == null ? "@ToJson" : "@FromJson";
|
||||
throw new IllegalArgumentException("No " + missingAnnotation + " adapter for "
|
||||
+ typeAnnotatedWithAnnotations(type, annotations));
|
||||
+ typeAnnotatedWithAnnotations(type, annotations), e);
|
||||
}
|
||||
} else {
|
||||
delegate = null;
|
||||
|
@@ -463,6 +463,9 @@ public final class AdapterMethodsTest {
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e).hasMessage("No @FromJson adapter for interface "
|
||||
+ "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) {
|
||||
assertThat(e).hasMessage("No @ToJson adapter for interface "
|
||||
+ "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) {
|
||||
assertThat(expected).hasMessage("No @FromJson adapter for class java.lang.String "
|
||||
+ "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) {
|
||||
assertThat(expected).hasMessage("No @ToJson adapter for class java.lang.String "
|
||||
+ "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