|
2 | 2 | // MIT-style license that can be found in the LICENSE file or at
|
3 | 3 | // https://opensource.org/licenses/MIT.
|
4 | 4 |
|
5 |
| -import 'dart:io'; |
6 | 5 | import 'dart:typed_data';
|
7 | 6 |
|
8 | 7 | import 'package:protobuf/protobuf.dart';
|
9 | 8 | import 'package:source_span/source_span.dart';
|
10 | 9 | import 'package:stack_trace/stack_trace.dart';
|
11 | 10 | import 'package:term_glyph/term_glyph.dart' as term_glyph;
|
12 | 11 |
|
| 12 | +import '../io.dart'; |
13 | 13 | import '../syntax.dart';
|
14 | 14 | import 'embedded_sass.pb.dart' as proto;
|
15 | 15 | import 'embedded_sass.pb.dart' hide SourceSpan, Syntax;
|
@@ -136,15 +136,17 @@ ProtocolError handleError(Object error, StackTrace stackTrace,
|
136 | 136 | {int? messageId}) {
|
137 | 137 | if (error is ProtocolError) {
|
138 | 138 | error.id = messageId ?? errorId;
|
139 |
| - stderr.write("Host caused ${error.type.name.toLowerCase()} error"); |
140 |
| - if (error.id != errorId) stderr.write(" with request ${error.id}"); |
141 |
| - stderr.writeln(": ${error.message}"); |
| 139 | + var buffer = StringBuffer(); |
| 140 | + buffer.write("Host caused ${error.type.name.toLowerCase()} error"); |
| 141 | + if (error.id != errorId) buffer.write(" with request ${error.id}"); |
| 142 | + buffer.write(": ${error.message}"); |
| 143 | + printError(buffer.toString()); |
142 | 144 | // PROTOCOL error from https://bit.ly/2poTt90
|
143 | 145 | exitCode = 76; // EX_PROTOCOL
|
144 | 146 | return error;
|
145 | 147 | } else {
|
146 | 148 | var errorMessage = "$error\n${Chain.forTrace(stackTrace)}";
|
147 |
| - stderr.write("Internal compiler error: $errorMessage"); |
| 149 | + printError("Internal compiler error: $errorMessage"); |
148 | 150 | exitCode = 70; // EX_SOFTWARE
|
149 | 151 | return ProtocolError()
|
150 | 152 | ..type = ProtocolErrorType.INTERNAL
|
|
0 commit comments