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 2b58ebfb40d0523e6da6ee00932821a843b750ac..6a5ace1f3ee8e8b5febf0bcd558c579adbf97ae9 100644 |
--- a/pkg/analysis_server/lib/src/analysis_server.dart |
+++ b/pkg/analysis_server/lib/src/analysis_server.dart |
@@ -892,35 +892,28 @@ class AnalysisServer { |
/** |
* Sends a `server.error` notification. |
*/ |
- void sendServerErrorNotification(String msg, exception, stackTrace, |
+ void sendServerErrorNotification(String message, exception, stackTrace, |
{bool fatal: false}) { |
- // prepare exception.toString() |
- String exceptionString; |
+ StringBuffer buffer = new StringBuffer(); |
if (exception != null) { |
- exceptionString = exception.toString(); |
+ buffer.write(exception); |
} else { |
- exceptionString = 'null exception'; |
+ buffer.write('null exception'); |
} |
- // prepare message |
- String message = msg != null ? '$msg\n$exceptionString' : exceptionString; |
- // prepare stackTrace.toString() |
- String stackTraceString; |
if (stackTrace != null) { |
- stackTraceString = stackTrace.toString(); |
- } else { |
+ buffer.writeln(); |
+ buffer.write(stackTrace); |
+ } else if (exception is! CaughtException) { |
try { |
throw 'ignored'; |
} catch (ignored, stackTrace) { |
- stackTraceString = stackTrace.toString(); |
- } |
- if (stackTraceString == null) { |
- // This code should be unreachable. |
- stackTraceString = 'null stackTrace'; |
+ buffer.writeln(); |
+ buffer.write(stackTrace); |
} |
} |
// send the notification |
channel.sendNotification( |
- new ServerErrorParams(fatal, message, stackTraceString) |
+ new ServerErrorParams(fatal, message, buffer.toString()) |
.toNotification()); |
} |