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_error; | 5 library schedule_error; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'schedule.dart'; | 9 import 'schedule.dart'; |
10 import 'task.dart'; | 10 import 'task.dart'; |
(...skipping 12 matching lines...) Expand all Loading... |
23 /// `null` if there was no such queue. | 23 /// `null` if there was no such queue. |
24 final TaskQueue queue; | 24 final TaskQueue queue; |
25 | 25 |
26 /// The state of the schedule at the time the error was detected. | 26 /// The state of the schedule at the time the error was detected. |
27 final ScheduleState _stateWhenDetected; | 27 final ScheduleState _stateWhenDetected; |
28 | 28 |
29 /// Creates a new [ScheduleError] wrapping [error]. The metadata in | 29 /// Creates a new [ScheduleError] wrapping [error]. The metadata in |
30 /// [AsyncError]s and [ScheduleError]s will be preserved. | 30 /// [AsyncError]s and [ScheduleError]s will be preserved. |
31 factory ScheduleError.from(Schedule schedule, error, {stackTrace, | 31 factory ScheduleError.from(Schedule schedule, error, {stackTrace, |
32 AsyncError cause}) { | 32 AsyncError cause}) { |
33 if (error is ScheduleError) { | 33 if (error is ScheduleError) return error; |
34 if (schedule == null) schedule = error.schedule; | |
35 } | |
36 | 34 |
37 if (error is AsyncError) { | 35 if (error is AsyncError) { |
38 // Overwrite the explicit stack trace, because it probably came from a | 36 // Overwrite the explicit stack trace, because it probably came from a |
39 // rethrow in the first place. | 37 // rethrow in the first place. |
40 stackTrace = error.stackTrace; | 38 stackTrace = error.stackTrace; |
41 if (cause == null) cause = error.cause; | 39 if (cause == null) cause = error.cause; |
42 error = error.error; | 40 error = error.error; |
43 } | 41 } |
44 | 42 |
45 return new ScheduleError(schedule, error, stackTrace, cause); | 43 return new ScheduleError(schedule, error, stackTrace, cause); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } else if (_stateWhenDetected == ScheduleState.RUNNING) { | 75 } else if (_stateWhenDetected == ScheduleState.RUNNING) { |
78 result.add('Error detected when waiting for out-of-band callbacks in ' | 76 result.add('Error detected when waiting for out-of-band callbacks in ' |
79 'queue "$queue".'); | 77 'queue "$queue".'); |
80 } else { // _stateWhenDetected == ScheduleState.SET_UP | 78 } else { // _stateWhenDetected == ScheduleState.SET_UP |
81 result.add('Error detected before the schedule started running.'); | 79 result.add('Error detected before the schedule started running.'); |
82 } | 80 } |
83 | 81 |
84 return result.toString(); | 82 return result.toString(); |
85 } | 83 } |
86 } | 84 } |
OLD | NEW |