OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 schedule; | 5 library schedule; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:unittest/unittest.dart' as unittest; | 10 import 'package:unittest/unittest.dart' as unittest; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return new Future.immediate(null).then((_) { | 126 return new Future.immediate(null).then((_) { |
127 try { | 127 try { |
128 setUp(); | 128 setUp(); |
129 } catch (e, stackTrace) { | 129 } catch (e, stackTrace) { |
130 throw new ScheduleError.from(this, e, stackTrace: stackTrace); | 130 throw new ScheduleError.from(this, e, stackTrace: stackTrace); |
131 } | 131 } |
132 | 132 |
133 _state = ScheduleState.RUNNING; | 133 _state = ScheduleState.RUNNING; |
134 return tasks._run(); | 134 return tasks._run(); |
135 }).catchError((e) { | 135 }).catchError((e) { |
136 errors.add(e); | 136 errors.add(new ScheduleError.from(this, e)); |
137 return onException._run().catchError((innerError) { | 137 return onException._run().catchError((innerError) { |
138 // If an error occurs in a task in the onException queue, make sure it's | 138 // If an error occurs in a task in the onException queue, make sure it's |
139 // registered in the error list and re-throw it. We could also re-throw | 139 // registered in the error list and re-throw it. We could also re-throw |
140 // `e`; ultimately, all the errors will be shown to the user if any | 140 // `e`; ultimately, all the errors will be shown to the user if any |
141 // ScheduleError is thrown. | 141 // ScheduleError is thrown. |
142 errors.add(innerError); | 142 errors.add(new ScheduleError.from(this, innerError)); |
143 throw innerError; | 143 throw innerError; |
144 }).then((_) { | 144 }).then((_) { |
145 // If there are no errors in the onException queue, re-throw the | 145 // If there are no errors in the onException queue, re-throw the |
146 // original error that caused it to run. | 146 // original error that caused it to run. |
147 throw e; | 147 throw e; |
148 }); | 148 }); |
149 }).whenComplete(() { | 149 }).whenComplete(() { |
150 return onComplete._run().catchError((e) { | 150 return onComplete._run().catchError((e) { |
151 // If an error occurs in a task in the onComplete queue, make sure it's | 151 // If an error occurs in a task in the onComplete queue, make sure it's |
152 // registered in the error list and re-throw it. | 152 // registered in the error list and re-throw it. |
153 errors.add(e); | 153 errors.add(new ScheduleError.from(this, e)); |
154 throw e; | 154 throw e; |
155 }); | 155 }); |
156 }).whenComplete(() { | 156 }).whenComplete(() { |
157 if (_timeoutTimer != null) _timeoutTimer.cancel(); | 157 if (_timeoutTimer != null) _timeoutTimer.cancel(); |
158 _state = ScheduleState.DONE; | 158 _state = ScheduleState.DONE; |
159 }); | 159 }); |
160 } | 160 } |
161 | 161 |
162 /// Signals that an out-of-band error has occurred. Using [wrapAsync] along | 162 /// Signals that an out-of-band error has occurred. Using [wrapAsync] along |
163 /// with `throw` is usually preferable to calling this directly. | 163 /// with `throw` is usually preferable to calling this directly. |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 return _contents.map((task) { | 411 return _contents.map((task) { |
412 var lines = task.toString().split("\n"); | 412 var lines = task.toString().split("\n"); |
413 var firstLine = task == highlight ? | 413 var firstLine = task == highlight ? |
414 "> ${lines.first}" : "* ${lines.first}"; | 414 "> ${lines.first}" : "* ${lines.first}"; |
415 lines = new List.from(lines.skip(1).map((line) => "| $line")); | 415 lines = new List.from(lines.skip(1).map((line) => "| $line")); |
416 lines.insertRange(0, 1, firstLine); | 416 lines.insertRange(0, 1, firstLine); |
417 return lines.join("\n"); | 417 return lines.join("\n"); |
418 }).join("\n"); | 418 }).join("\n"); |
419 } | 419 } |
420 } | 420 } |
OLD | NEW |