Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2261)

Unified Diff: dart/tests/compiler/dart2js/mock_compiler.dart

Issue 20742002: Clean up error handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added documentation guide lines. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/tests/compiler/dart2js/mock_compiler.dart
diff --git a/dart/tests/compiler/dart2js/mock_compiler.dart b/dart/tests/compiler/dart2js/mock_compiler.dart
index 750dc2e12e119c0df92e94d1b69a30481749afc0..950a7e5ebbc2cb3eebb519ac4a7847a7ff739cd5 100644
--- a/dart/tests/compiler/dart2js/mock_compiler.dart
+++ b/dart/tests/compiler/dart2js/mock_compiler.dart
@@ -30,7 +30,7 @@ import '../../../sdk/lib/_internal/compiler/implementation/deferred_load.dart'
class WarningMessage {
- Node node;
+ Spannable node;
Message message;
WarningMessage(this.node, this.message);
@@ -281,6 +281,7 @@ class MockCompiler extends Compiler {
Uri uri = new Uri(scheme: "dart", path: name);
var script = new Script(uri, new MockFile(source));
var library = new LibraryElementX(script);
+ library.libraryTag = new LibraryName(null, null, null);
parseScript(source, library);
library.setExports(library.localScope.values.toList());
registerSource(uri, source);
@@ -295,15 +296,18 @@ class MockCompiler extends Compiler {
'Warning: $message', api.Diagnostic.WARNING);
}
- void reportError(Node node, var message) {
- if (message is String && message.startsWith("no library name found in")) {
- // TODO(ahe): Fix the MockCompiler to not have this problem.
- return;
- }
- if (message is! Message) message = message.message;
+ void reportError(Spannable node,
+ MessageKind errorCode,
+ [Map arguments = const {}]) {
+ Message message = errorCode.message(arguments);
errors.add(new WarningMessage(node, message));
- reportDiagnostic(spanFromNode(node),
- 'Error: $message', api.Diagnostic.ERROR);
+ reportDiagnostic(spanFromSpannable(node), '$message', api.Diagnostic.ERROR);
+ }
+
+ void reportFatalError(Spannable node,
+ MessageKind errorCode,
+ [Map arguments = const {}]) {
+ reportError(node, errorCode, arguments);
}
void reportMessage(SourceSpan span, var message, api.Diagnostic kind) {

Powered by Google App Engine
This is Rietveld 408576698