Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library fasta.errors; | 5 library fasta.errors; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:convert' show JSON; | 9 import 'dart:convert' show JSON; |
| 10 | 10 |
| 11 import 'dart:io' | 11 import 'dart:io' |
| 12 show ContentType, HttpClient, HttpClientRequest, SocketException, stderr; | 12 show ContentType, HttpClient, HttpClientRequest, SocketException, stderr; |
| 13 | 13 |
| 14 import 'colors.dart' show red; | 14 import 'colors.dart' show red; |
| 15 | 15 |
| 16 import 'messages.dart' show errorsAreFatal, deprecated_format, isVerbose; | 16 import 'messages.dart' show errorsAreFatal, deprecated_format, isVerbose; |
| 17 | 17 |
| 18 import 'fasta_codes.dart' show Message, LocatedMessage, Code; | |
| 19 | |
| 18 const String defaultServerAddress = "http://127.0.0.1:59410/"; | 20 const String defaultServerAddress = "http://127.0.0.1:59410/"; |
| 19 | 21 |
| 20 /// Tracks if there has been a crash reported through [reportCrash]. Should be | 22 /// Tracks if there has been a crash reported through [reportCrash]. Should be |
| 21 /// reset between each compilation by calling [resetCrashReporting]. | 23 /// reset between each compilation by calling [resetCrashReporting]. |
| 22 bool hasCrashed = false; | 24 bool hasCrashed = false; |
| 23 | 25 |
| 24 /// Tracks the first source URI that has been read and is used as a fall-back | 26 /// Tracks the first source URI that has been read and is used as a fall-back |
| 25 /// for [reportCrash]. Should be reset between each compilation by calling | 27 /// for [reportCrash]. Should be reset between each compilation by calling |
| 26 /// [resetCrashReporting]. | 28 /// [resetCrashReporting]. |
| 27 Uri firstSourceUri; | 29 Uri firstSourceUri; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 String deprecated_formatUnexpected(Uri uri, int charOffset, String message) { | 76 String deprecated_formatUnexpected(Uri uri, int charOffset, String message) { |
| 75 return deprecated_format(uri, charOffset, colorError("Error: $message")); | 77 return deprecated_format(uri, charOffset, colorError("Error: $message")); |
| 76 } | 78 } |
| 77 | 79 |
| 78 String colorError(String message) { | 80 String colorError(String message) { |
| 79 // TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on | 81 // TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on |
| 80 // Windows. | 82 // Windows. |
| 81 return red(message); | 83 return red(message); |
| 82 } | 84 } |
| 83 | 85 |
| 84 class deprecated_InputError { | 86 class deprecated_InputError implements LocatedMessage { |
|
ahe
2017/07/12 13:14:43
I would like to maintain the invariant that instan
Siggi Cherem (dart-lang)
2017/07/12 21:54:59
Done (removed the implements here)
| |
| 85 final Uri uri; | 87 final Uri uri; |
| 86 | 88 |
| 87 final int charOffset; | 89 final int charOffset; |
| 88 | 90 |
| 89 final Object error; | 91 final Object error; |
| 90 | 92 |
| 93 String get message => safeToString(error); | |
| 94 | |
| 95 Message get messageObject => null; | |
| 96 | |
| 97 Code get code => null; | |
| 98 | |
| 99 Map<String, dynamic> get arguments => {}; | |
| 100 | |
| 101 String get tip => null; | |
| 102 | |
| 91 deprecated_InputError(this.uri, int charOffset, this.error) | 103 deprecated_InputError(this.uri, int charOffset, this.error) |
| 92 : this.charOffset = charOffset ?? -1; | 104 : this.charOffset = charOffset ?? -1; |
| 93 | 105 |
| 94 toString() => "deprecated_InputError: $error"; | 106 toString() => "deprecated_InputError: $error"; |
| 95 | 107 |
| 96 String deprecated_format() => | 108 String deprecated_format() => |
| 97 deprecated_formatUnexpected(uri, charOffset, safeToString(error)); | 109 deprecated_formatUnexpected(uri, charOffset, safeToString(error)); |
| 98 } | 110 } |
| 99 | 111 |
| 100 class Crash { | 112 class Crash { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 return new Future.error(error, trace); | 190 return new Future.error(error, trace); |
| 179 } | 191 } |
| 180 | 192 |
| 181 String safeToString(Object object) { | 193 String safeToString(Object object) { |
| 182 try { | 194 try { |
| 183 return "$object"; | 195 return "$object"; |
| 184 } catch (e) { | 196 } catch (e) { |
| 185 return "Error when converting ${object.runtimeType} to string."; | 197 return "Error when converting ${object.runtimeType} to string."; |
| 186 } | 198 } |
| 187 } | 199 } |
| OLD | NEW |