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

Side by Side Diff: lib/src/runner/browser/content_shell.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 unified diff | Download patch
« no previous file with comments | « lib/src/runner/browser/chrome.dart ('k') | lib/src/runner/browser/dartium.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.runner.browser.content_shell; 5 library test.runner.browser.content_shell;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 import 'package:stack_trace/stack_trace.dart';
12
13 import '../../utils.dart';
11 import '../application_exception.dart'; 14 import '../application_exception.dart';
12 import 'browser.dart'; 15 import 'browser.dart';
13 16
14 /// A converter that transforms a byte stream into a stream of lines. 17 /// A converter that transforms a byte stream into a stream of lines.
15 final _lines = UTF8.decoder.fuse(const LineSplitter()); 18 final _lines = UTF8.decoder.fuse(const LineSplitter());
16 19
17 /// A class for running an instance of the Dartium content shell. 20 /// A class for running an instance of the Dartium content shell.
18 /// 21 ///
19 /// Most of the communication with the browser is expected to happen via HTTP, 22 /// Most of the communication with the browser is expected to happen via HTTP,
20 /// so this exposes a bare-bones API. The browser starts as soon as the class is 23 /// so this exposes a bare-bones API. The browser starts as soon as the class is
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // TODO(nweiz): link to dartlang.org once it has download links for 67 // TODO(nweiz): link to dartlang.org once it has download links for
65 // content shell 68 // content shell
66 // (https://github.com/dart-lang/www.dartlang.org/issues/1164). 69 // (https://github.com/dart-lang/www.dartlang.org/issues/1164).
67 throw new ApplicationException( 70 throw new ApplicationException(
68 "You're using an expired content_shell. Upgrade to the latest " 71 "You're using an expired content_shell. Upgrade to the latest "
69 "version:\n" 72 "version:\n"
70 "http://gsdview.appspot.com/dart-archive/channels/stable/release/" 73 "http://gsdview.appspot.com/dart-archive/channels/stable/release/"
71 "latest/dartium/"); 74 "latest/dartium/");
72 } 75 }
73 76
74 if (exitCode != 0) throw "Content shell failed with exit code $exitCode."; 77 if (exitCode == 0) return null;
75 }).then(_onExitCompleter.complete) 78
76 .catchError(_onExitCompleter.completeError); 79
80 return UTF8.decodeStream(_process.stderr).then((error) {
81 throw new ApplicationException(
82 "Content shell failed with exit code $exitCode:\n$error");
83 });
84 }).then(_onExitCompleter.complete).catchError((error, stackTrace) {
85 if (stackTrace == null) stackTrace = new Trace.current();
86 _onExitCompleter.completeError(
87 new ApplicationException(
88 "Failed to start content shell: ${getErrorMessage(error)}."),
89 stackTrace);
90 });
77 } 91 }
78 92
79 Future close() { 93 Future close() {
80 _onProcessStarted.then((_) => _process.kill()); 94 _onProcessStarted.then((_) => _process.kill());
81 95
82 // Swallow exceptions. The user should explicitly use [onExit] for these. 96 // Swallow exceptions. The user should explicitly use [onExit] for these.
83 return onExit.catchError((_) {}); 97 return onExit.catchError((_) {});
84 } 98 }
85 99
86 /// Return the default executable for the current operating system. 100 /// Return the default executable for the current operating system.
87 String _defaultExecutable() => 101 String _defaultExecutable() =>
88 Platform.isWindows ? "content_shell.exe" : "content_shell"; 102 Platform.isWindows ? "content_shell.exe" : "content_shell";
89 } 103 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/chrome.dart ('k') | lib/src/runner/browser/dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698