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

Unified Diff: lib/src/runner/browser/phantom_js.dart

Issue 1091883002: More gracefully handle browser errors. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: merge Created 5 years, 8 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/runner/browser/firefox.dart ('k') | lib/src/runner/browser/safari.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/browser/phantom_js.dart
diff --git a/lib/src/runner/browser/phantom_js.dart b/lib/src/runner/browser/phantom_js.dart
index 0eadafb4512d767c8558ae00c2a476508469f4da..c13ee63fb6c24f53f5056d635ddb3e98f504d660 100644
--- a/lib/src/runner/browser/phantom_js.dart
+++ b/lib/src/runner/browser/phantom_js.dart
@@ -5,12 +5,15 @@
library test.runner.browser.phantom_js;
import 'dart:async';
+import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as p;
+import 'package:stack_trace/stack_trace.dart';
import '../../util/exit_codes.dart' as exit_codes;
import '../../util/io.dart';
+import '../../utils.dart';
import '../application_exception.dart';
import 'browser.dart';
@@ -82,9 +85,20 @@ class PhantomJS implements Browser {
throw new ApplicationException(
"Only PhantomJS version 2.0.0 or greater is supported.");
}
- if (exitCode != 0) throw "PhantomJS failed with exit code $exitCode.";
- }).then(_onExitCompleter.complete)
- .catchError(_onExitCompleter.completeError);
+
+ if (exitCode == 0) return null;
+
+ return UTF8.decodeStream(_process.stderr).then((error) {
+ throw new ApplicationException(
+ "PhantomJS failed with exit code $exitCode:\n$error");
+ });
+ }).then(_onExitCompleter.complete).catchError((error, stackTrace) {
+ if (stackTrace == null) stackTrace = new Trace.current();
+ _onExitCompleter.completeError(
+ new ApplicationException(
+ "Failed to start PhantomJS: ${getErrorMessage(error)}."),
+ stackTrace);
+ });
}
Future close() {
« no previous file with comments | « lib/src/runner/browser/firefox.dart ('k') | lib/src/runner/browser/safari.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698