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

Unified Diff: compiler/java/com/google/dart/compiler/DartCompiler.java

Issue 8855010: Report error on parsing URI cleanly (don't throw exception) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/DartCompilerErrorCode.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/DartCompiler.java
diff --git a/compiler/java/com/google/dart/compiler/DartCompiler.java b/compiler/java/com/google/dart/compiler/DartCompiler.java
index 8d0e8253eb1c8628180bf899a67bd0916ace6bf1..f589f283bab77e4bedb926957f3fbc407e32d299 100644
--- a/compiler/java/com/google/dart/compiler/DartCompiler.java
+++ b/compiler/java/com/google/dart/compiler/DartCompiler.java
@@ -356,7 +356,12 @@ public class DartCompiler {
if (SystemLibraryManager.isDartSpec(libSpec)) {
dep = context.getSystemLibraryFor(libSpec);
} else {
- dep = libSrc.getImportFor(libSpec);
+ try {
+ dep = libSrc.getImportFor(libSpec);
+ } catch (IllegalArgumentException ex) {
+ reportImportError(context, libSrc, libNode);
+ continue;
+ }
}
if (dep == null) {
reportMissingSource(context, libSrc, libNode);
@@ -674,7 +679,7 @@ public class DartCompiler {
try {
// Set entry point
setEntryPoint();
-
+
// Dump the compiler parse tree if dump format is set in arguments
BaseASTWriter astWriter = ASTWriterFactory.create(config);
@@ -684,11 +689,11 @@ public class DartCompiler {
// Compile all the units in this library.
for (DartUnit unit : lib.getUnits()) {
-
+
if(astWriter != null) {
astWriter.process(unit);
}
-
+
// Don't compile api-only units.
if (unit.isDiet()) {
continue;
@@ -850,6 +855,14 @@ public class DartCompiler {
context.onError(event);
}
+ private void reportImportError(DartCompilerContext context,
+ LibrarySource libSrc,
+ LibraryNode libNode) {
+ DartCompilationError event = new DartCompilationError(libNode,
+ DartCompilerErrorCode.COULD_NOT_PARSE_IMPORT, libNode.getText());
+ event.setSource(libSrc);
+ context.onError(event);
+ }
CoreTypeProvider getTypeProvider() {
typeProvider.getClass(); // Quick null check.
return typeProvider;
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/DartCompilerErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698