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

Unified Diff: lib/src/load_exception.dart

Issue 933083002: Add a test runner executable. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes Created 5 years, 10 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 | « lib/src/invoker.dart ('k') | lib/src/loader.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/load_exception.dart
diff --git a/lib/src/load_exception.dart b/lib/src/load_exception.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8c6dff0d48073409e429c7baf6f385c1aaaebf22
--- /dev/null
+++ b/lib/src/load_exception.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library unittest.load_exception;
+
+import 'dart:isolate';
+
+import 'package:path/path.dart' as p;
+
+import 'utils.dart';
+
+class LoadException implements Exception {
+ final String path;
+
+ final innerError;
+
+ LoadException(this.path, this.innerError);
+
+ String toString() {
+ var buffer = new StringBuffer('Failed to load "$path":');
+
+ var innerString = getErrorMessage(innerError);
+ if (innerError is IsolateSpawnException) {
+ // If this is a parse error, get rid of the noisy preamble.
+ innerString = innerString
+ .replaceFirst("'${p.toUri(p.absolute(path))}': error: ", "");
+
+ // If this is a file system error, get rid of both the preamble and the
+ // useless stack trace.
+ innerString = innerString.replaceFirst(
+ "Unhandled exception:\n"
+ "Uncaught Error: Load Error: FileSystemException: ",
+ "");
+ innerString = innerString.split("Stack Trace:\n").first.trim();
+ }
+
+ buffer.write(innerString.contains("\n") ? "\n" : " ");
+ buffer.write(innerString);
+ return buffer.toString();
+ }
+}
« no previous file with comments | « lib/src/invoker.dart ('k') | lib/src/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698