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

Unified Diff: runtime/bin/process_impl.dart

Issue 10173024: Change the error handling in dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « runtime/bin/process.dart ('k') | runtime/bin/socket.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_impl.dart
diff --git a/runtime/bin/process_impl.dart b/runtime/bin/process_impl.dart
index bb722500b51370f3da49b0102b8bcbcb3c9a8e57..6c11501a837a197a7b9b736980ebb8395eac9883 100644
--- a/runtime/bin/process_impl.dart
+++ b/runtime/bin/process_impl.dart
@@ -166,10 +166,8 @@ class _InteractiveProcess implements Process {
status);
if (!success) {
close();
- if (_onError !== null) {
- _onError(new ProcessException(status._errorMessage, status._errorCode));
- return;
- }
+ _reportError(new ProcessException(status._errorMessage, status._errorCode));
+ return;
}
_started = true;
@@ -242,9 +240,7 @@ class _InteractiveProcess implements Process {
void kill() {
if (_closed && _pid === null) {
- if (_onError !== null) {
- _onError(new ProcessException("Process closed"));
- }
+ _reportError(new ProcessException("Process closed"));
return;
}
if (_killed) {
@@ -255,10 +251,8 @@ class _InteractiveProcess implements Process {
_killed = true;
return;
}
- if (_onError !== null) {
- _onError(new ProcessException("Could not kill process"));
- return;
- }
+ _reportError(new ProcessException("Could not kill process"));
+ return;
}
void _kill(int pid) native "Process_Kill";
@@ -284,7 +278,7 @@ class _InteractiveProcess implements Process {
_onExit = callback;
}
- void set onError(void callback(ProcessException exception)) {
+ void set onError(void callback(e)) {
_onError = callback;
}
@@ -292,6 +286,14 @@ class _InteractiveProcess implements Process {
_onStart = callback;
}
+ void _reportError(e) {
+ if (_onError != null) {
+ _onError(e);
+ } else {
+ throw e;
+ }
+ }
+
String _path;
ObjectArray<String> _arguments;
String _workingDirectory;
@@ -409,7 +411,7 @@ class _NonInteractiveProcess implements Process {
'be supplied in the callback on completion.');
}
- void set onError(void callback(ProcessException error)) {
+ void set onError(void callback(e)) {
_process.onError = callback;
}
« no previous file with comments | « runtime/bin/process.dart ('k') | runtime/bin/socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698