| Index: pkg/analysis_server/lib/src/analysis_server.dart
|
| diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
|
| index fa718fccb2b69a3414156bfefcddec26274259f5..546859f79381a13a9be471321679340aa3c4446a 100644
|
| --- a/pkg/analysis_server/lib/src/analysis_server.dart
|
| +++ b/pkg/analysis_server/lib/src/analysis_server.dart
|
| @@ -13,6 +13,7 @@ import 'package:analysis_server/protocol/protocol_generated.dart'
|
| hide AnalysisOptions;
|
| import 'package:analysis_server/src/analysis_logger.dart';
|
| import 'package:analysis_server/src/channel/channel.dart';
|
| +import 'package:analysis_server/src/collections.dart';
|
| import 'package:analysis_server/src/computer/computer_highlights.dart';
|
| import 'package:analysis_server/src/computer/computer_highlights2.dart';
|
| import 'package:analysis_server/src/computer/computer_outline.dart';
|
| @@ -262,6 +263,12 @@ class AnalysisServer {
|
| }
|
|
|
| /**
|
| + * A [RecentBuffer] of the most recent exceptions encountered by the analysis
|
| + * server.
|
| + */
|
| + final RecentBuffer<ServerException> exceptions = new RecentBuffer(10);
|
| +
|
| + /**
|
| * The class into which performance information is currently being recorded.
|
| * During startup, this will be the same as [performanceDuringStartup]
|
| * and after startup is complete, this switches to [performanceAfterStartup].
|
| @@ -1233,26 +1240,26 @@ class AnalysisServer {
|
| void sendServerErrorNotification(String message, exception, stackTrace,
|
| {bool fatal: false}) {
|
| StringBuffer buffer = new StringBuffer();
|
| - if (exception != null) {
|
| - buffer.write(exception);
|
| - } else {
|
| - buffer.write('null exception');
|
| - }
|
| + buffer.write(exception ?? 'null exception');
|
| if (stackTrace != null) {
|
| buffer.writeln();
|
| buffer.write(stackTrace);
|
| } else if (exception is! CaughtException) {
|
| - try {
|
| - throw 'ignored';
|
| - } catch (ignored, stackTrace) {
|
| - buffer.writeln();
|
| - buffer.write(stackTrace);
|
| - }
|
| + stackTrace = StackTrace.current;
|
| + buffer.writeln();
|
| + buffer.write(stackTrace);
|
| }
|
| +
|
| // send the notification
|
| channel.sendNotification(
|
| new ServerErrorParams(fatal, message, buffer.toString())
|
| .toNotification());
|
| +
|
| + // remember the last few exceptions
|
| + if (exception is CaughtException) {
|
| + stackTrace ??= exception.stackTrace;
|
| + }
|
| + exceptions.add(new ServerException(message, exception, stackTrace, fatal));
|
| }
|
|
|
| /**
|
| @@ -2384,3 +2391,18 @@ class ServerPerformanceStatistics {
|
| */
|
| static PerformanceTag splitStore = new PerformanceTag('splitStore');
|
| }
|
| +
|
| +/**
|
| + * Used to record server exceptions.
|
| + */
|
| +class ServerException {
|
| + final String message;
|
| + final dynamic exception;
|
| + final StackTrace stackTrace;
|
| + final bool fatal;
|
| +
|
| + ServerException(this.message, this.exception, this.stackTrace, this.fatal);
|
| +
|
| + @override
|
| + String toString() => message;
|
| +}
|
|
|