mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:10:22 +00:00
[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:
parent
b19436061d
commit
18b7580944
|
@ -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,
|
||||
|
|
|
@ -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, ...).
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue