diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java index e2a5bc7cef..8050292174 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java @@ -288,7 +288,8 @@ public class StandardMessageCodec implements MessageCodec { writeFloat(stream, f); } } else { - throw new IllegalArgumentException("Unsupported value: " + value); + throw new IllegalArgumentException( + "Unsupported value: '" + value + "' of type '" + value.getClass() + "'"); } } diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/StandardMessageCodecTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/StandardMessageCodecTest.java index 96f7908848..4f7f14a635 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/StandardMessageCodecTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/StandardMessageCodecTest.java @@ -2,6 +2,8 @@ package io.flutter.plugin.common; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; import android.text.SpannableString; import java.nio.ByteBuffer; @@ -122,4 +124,24 @@ public class StandardMessageCodecTest { String value = (String) codec.decodeMessage(message); assertEquals(value, "hello world"); } + + private static class NotEncodable { + @Override + public String toString() { + return "not encodable"; + } + } + + @Test + public void errorHasType() { + StandardMessageCodec codec = new StandardMessageCodec(); + NotEncodable notEncodable = new NotEncodable(); + Exception exception = + assertThrows( + IllegalArgumentException.class, + () -> { + codec.encodeMessage(notEncodable); + }); + assertTrue(exception.getMessage().contains("NotEncodable")); + } }