From 33e25fa6070e1ddaeb857ddeb1a621ca9eda825a Mon Sep 17 00:00:00 2001 From: Amir Hardon Date: Thu, 22 Aug 2019 09:02:31 -0700 Subject: [PATCH] Include Java stack trace in method channel invocations (flutter/engine#11361) --- .../systemchannels/PlatformViewsChannel.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java index 0e2c3ed0ff..15188b968b 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java @@ -7,6 +7,8 @@ package io.flutter.embedding.engine.systemchannels; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import java.io.PrintWriter; +import java.io.StringWriter; import java.nio.ByteBuffer; import java.util.List; import java.util.Map; @@ -36,6 +38,13 @@ public class PlatformViewsChannel { channel.invokeMethod("viewFocused", viewId); } + private static String detailedExceptionString(Exception exception) { + StringWriter stringWriter = new StringWriter(); + PrintWriter printWriter = new PrintWriter(stringWriter); + exception.printStackTrace(printWriter); + return stringWriter.toString(); + } + private final MethodChannel.MethodCallHandler parsingHandler = new MethodChannel.MethodCallHandler() { @Override public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { @@ -89,7 +98,7 @@ public class PlatformViewsChannel { } catch (IllegalStateException exception) { result.error( "error", - exception.getMessage(), + detailedExceptionString(exception), null ); } @@ -103,7 +112,7 @@ public class PlatformViewsChannel { } catch (IllegalStateException exception) { result.error( "error", - exception.getMessage(), + detailedExceptionString(exception), null ); } @@ -129,7 +138,7 @@ public class PlatformViewsChannel { } catch (IllegalStateException exception) { result.error( "error", - exception.getMessage(), + detailedExceptionString(exception), null ); } @@ -161,7 +170,7 @@ public class PlatformViewsChannel { } catch (IllegalStateException exception) { result.error( "error", - exception.getMessage(), + detailedExceptionString(exception), null ); } @@ -181,7 +190,7 @@ public class PlatformViewsChannel { } catch (IllegalStateException exception) { result.error( "error", - exception.getMessage(), + detailedExceptionString(exception), null ); } @@ -195,7 +204,7 @@ public class PlatformViewsChannel { } catch (IllegalStateException exception) { result.error( "error", - exception.getMessage(), + detailedExceptionString(exception), null ); }