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

Unified Diff: lib/src/compiler/compiler.dart

Issue 2161693002: Catch file-not-found exception (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: AnalysisException -> UsageException Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/compiler/compiler.dart
diff --git a/lib/src/compiler/compiler.dart b/lib/src/compiler/compiler.dart
index 6355dcfb17485850c1f094aaa6b85c127a0808e4..8bc3b307cd6a123264296a320e5de1421bd82d62 100644
--- a/lib/src/compiler/compiler.dart
+++ b/lib/src/compiler/compiler.dart
@@ -4,6 +4,7 @@
import 'dart:collection' show HashSet;
import 'package:args/args.dart' show ArgParser, ArgResults;
+import 'package:args/src/usage_exception.dart' show UsageException;
import 'package:analyzer/analyzer.dart'
show
AnalysisError,
@@ -12,7 +13,6 @@ import 'package:analyzer/analyzer.dart'
ErrorSeverity,
StaticWarningCode;
import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
-import 'package:analyzer/src/generated/java_engine.dart' show AnalysisException;
import 'package:analyzer/src/generated/source_io.dart' show Source, SourceKind;
import 'package:func/func.dart' show Func1;
import 'package:path/path.dart' as path;
@@ -77,9 +77,17 @@ class ModuleCompiler {
sourceUri = path.toUri(path.absolute(sourcePath));
}
Source source = context.sourceFactory.forUri2(sourceUri);
+
+ var fileUsage = 'You need to pass at least one existing .dart file as an'
+ ' argument.';
if (source == null) {
- throw new AnalysisException('could not create a source for $sourcePath.'
- ' The file name is in the wrong format or was not found.');
+ throw new UsageException(
+ 'Could not create a source for "$sourcePath". The file name is in'
+ ' the wrong format or was not found.',
+ fileUsage);
+ } else if (!source.exists()) {
+ throw new UsageException(
+ 'Given file "$sourcePath" does not exist.', fileUsage);
}
// Ignore parts. They need to be handled in the context of their library.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698