[analyzer] for 'Failed to handle request' errors, send the exception to crash reporting as well

Change-Id: Id50543fe6cac0e60ec32bfc6860064b210514dca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125988
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
Devon Carew 2019-11-25 20:20:46 +00:00 committed by commit-bot@chromium.org
parent b19436061d
commit 18b7580944
4 changed files with 22 additions and 24 deletions

View file

@ -416,26 +416,20 @@ class AnalysisServer extends AbstractAnalysisServer {
/*StackTrace*/ stackTrace, {
bool fatal = false,
}) {
StringBuffer buffer = new StringBuffer();
buffer.write(exception ?? 'null exception');
if (stackTrace != null) {
buffer.writeln();
buffer.write(stackTrace);
} else if (exception is! CaughtException) {
String msg = exception == null ? message : '$message: $exception';
if (stackTrace != null && exception is! CaughtException) {
stackTrace = StackTrace.current;
buffer.writeln();
buffer.write(stackTrace);
}
// send the notification
channel.sendNotification(
new ServerErrorParams(fatal, message, buffer.toString())
.toNotification());
new ServerErrorParams(fatal, msg, '$stackTrace').toNotification());
// remember the last few exceptions
if (exception is CaughtException) {
stackTrace ??= exception.stackTrace;
}
exceptions.add(new ServerException(
message,
exception,

View file

@ -16,24 +16,28 @@ class CrashReportingInstrumentation extends NoopInstrumentationService {
void logException(dynamic exception, [StackTrace stackTrace]) {
if (exception is CaughtException) {
// Get the root CaughtException, which matters most for debugging.
exception = exception.rootCaughtException;
// Report the root exception stack trace.
stackTrace = exception.stackTrace;
// Report the dynamic exception object that the CaughtException holds.
exception = exception.exception;
CaughtException root = exception.rootCaughtException;
reporter.sendReport(root.exception, root.stackTrace).catchError((error) {
// We silently ignore errors sending crash reports (network issues, ...).
});
} else {
reporter
.sendReport(exception, stackTrace ?? StackTrace.current)
.catchError((error) {
// We silently ignore errors sending crash reports (network issues, ...).
});
}
reporter
.sendReport(exception, stackTrace: stackTrace ?? StackTrace.current)
.catchError((error) {
// We silently ignore errors sending crash reports (network issues, ...).
});
}
@override
void logPluginException(
PluginData plugin, dynamic exception, StackTrace stackTrace) {
PluginData plugin,
dynamic exception,
StackTrace stackTrace,
) {
// TODO(mfairhurst): send plugin information too.
reporter.sendReport(exception, stackTrace: stackTrace).catchError((error) {
reporter.sendReport(exception, stackTrace).catchError((error) {
// We silently ignore errors sending crash reports (network issues, ...).
});
}

View file

@ -56,7 +56,7 @@ class CrashReportSender {
/// Sends one crash report.
///
/// The report is populated from data in [error] and [stackTrace].
Future sendReport(dynamic error, {StackTrace stackTrace}) async {
Future sendReport(dynamic error, StackTrace stackTrace) async {
if (!shouldSend()) {
return;
}

View file

@ -33,7 +33,7 @@ void main() {
analytics.trackingId, shouldSend,
httpClient: mockClient);
await sender.sendReport('test-error', stackTrace: StackTrace.current);
await sender.sendReport('test-error', StackTrace.current);
String body = utf8.decode(request.bodyBytes);
expect(body, contains('String')); // error.runtimeType