From 68149fc6bea219fe2a7e108ed99be0d03d75cd35 Mon Sep 17 00:00:00 2001
From: "rnystrom@google.com" <rnystrom@google.com>
Date: Tue, 7 May 2013 00:11:44 +0000
Subject: [PATCH] Don't show a stack trace on a bad path dependency path.

This is a user-facing error, so there shouldn't be a stack dump.

BUG=https://code.google.com/p/dart/issues/detail?id=10123
R=nweiz@google.com

Review URL: https://codereview.chromium.org//14662003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge@22448 260f80e4-7a28-3924-810f-c04153c831b5
---
 lib/src/path_source.dart                    | 9 ++++-----
 test/install/path/nonexistent_dir_test.dart | 3 +--
 test/install/path/path_is_file_test.dart    | 3 +--
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/lib/src/path_source.dart b/lib/src/path_source.dart
index 72d40659..7d639359 100644
--- a/lib/src/path_source.dart
+++ b/lib/src/path_source.dart
@@ -110,18 +110,17 @@ class PathSource extends Source {
 
   /// Ensures that [description] is a valid path description. It must be a map,
   /// with a "path" key containing a path that points to an existing directory.
-  /// Throws a [FormatException] if the path is invalid.
+  /// Throws an [ApplicationException] if the path is invalid.
   void _validatePath(String name, description) {
     var dir = description["path"];
 
     if (dirExists(dir)) return;
 
     if (fileExists(dir)) {
-      throw new FormatException(
-          "Path dependency for package '$name' must refer to a "
-          "directory, not a file. Was '$dir'.");
+      fail("Path dependency for package '$name' must refer to a "
+           "directory, not a file. Was '$dir'.");
     }
 
-    throw new FormatException("Could not find package '$name' at '$dir'.");
+    fail("Could not find package '$name' at '$dir'.");
   }
 }
diff --git a/test/install/path/nonexistent_dir_test.dart b/test/install/path/nonexistent_dir_test.dart
index 7220cb9c..053c9225 100644
--- a/test/install/path/nonexistent_dir_test.dart
+++ b/test/install/path/nonexistent_dir_test.dart
@@ -7,7 +7,6 @@ import 'dart:io';
 import 'package:pathos/path.dart' as path;
 import 'package:scheduled_test/scheduled_test.dart';
 
-import '../../../lib/src/exit_codes.dart' as exit_codes;
 import '../../descriptor.dart' as d;
 import '../../test_pub.dart';
 
@@ -34,6 +33,6 @@ main() {
     schedulePub(args: ['install'],
         error:
             new RegExp("Could not find package 'foo' at '$escapePath'."),
-        exitCode: exit_codes.DATA);
+        exitCode: 1);
   });
 }
\ No newline at end of file
diff --git a/test/install/path/path_is_file_test.dart b/test/install/path/path_is_file_test.dart
index 32f71803..7779467b 100644
--- a/test/install/path/path_is_file_test.dart
+++ b/test/install/path/path_is_file_test.dart
@@ -5,7 +5,6 @@
 import 'package:pathos/path.dart' as path;
 import 'package:scheduled_test/scheduled_test.dart';
 
-import '../../../lib/src/exit_codes.dart' as exit_codes;
 import '../../descriptor.dart' as d;
 import '../../test_pub.dart';
 
@@ -38,6 +37,6 @@ main() {
     schedulePub(args: ['install'],
         error: new RegExp("Path dependency for package 'foo' must refer to a "
                           "directory, not a file. Was '$escapePath'."),
-        exitCode: exit_codes.DATA);
+        exitCode: 1);
   });
 }
\ No newline at end of file
-- 
GitLab