| 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 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 /// The task that was running when this error occurred. This may be `null` if | 26 /// The task that was running when this error occurred. This may be `null` if |
| 27 /// there was no such task. | 27 /// there was no such task. |
| 28 final Task task; | 28 final Task task; |
| 29 | 29 |
| 30 /// The task queue that was running when this error occured. This may be | 30 /// The task queue that was running when this error occured. This may be |
| 31 /// `null` if there was no such queue. | 31 /// `null` if there was no such queue. |
| 32 final TaskQueue queue; | 32 final TaskQueue queue; |
| 33 | 33 |
| 34 /// The descriptions of out-of-band callbacks that were pending when this | 34 /// The descriptions of out-of-band callbacks that were pending when this |
| 35 /// error occurred. | 35 /// error occurred. |
| 36 final Iterable<String> pendingCallbacks; | 36 final Iterable<PendingCallback> pendingCallbacks; |
| 37 | 37 |
| 38 /// The state of the schedule at the time the error was detected. | 38 /// The state of the schedule at the time the error was detected. |
| 39 final ScheduleState _stateWhenDetected; | 39 final ScheduleState _stateWhenDetected; |
| 40 | 40 |
| 41 int get hashCode => schedule.hashCode ^ task.hashCode ^ queue.hashCode ^ | 41 int get hashCode => schedule.hashCode ^ task.hashCode ^ queue.hashCode ^ |
| 42 _stateWhenDetected.hashCode ^ error.hashCode ^ stackTrace.hashCode; | 42 _stateWhenDetected.hashCode ^ error.hashCode ^ stackTrace.hashCode; |
| 43 | 43 |
| 44 /// Creates a new [ScheduleError] wrapping [error]. The metadata in | 44 /// Creates a new [ScheduleError] wrapping [error]. The metadata in |
| 45 /// [ScheduleError]s will be preserved. | 45 /// [ScheduleError]s will be preserved. |
| 46 factory ScheduleError.from(Schedule schedule, error, | 46 factory ScheduleError.from(Schedule schedule, error, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 // TODO(floitsch): restore StackTrace type when it has been integrated into | 64 // TODO(floitsch): restore StackTrace type when it has been integrated into |
| 65 // the core libraries. | 65 // the core libraries. |
| 66 ScheduleError(Schedule schedule, error, var stackTrace) | 66 ScheduleError(Schedule schedule, error, var stackTrace) |
| 67 : error = error, | 67 : error = error, |
| 68 stackTrace = stackTrace, | 68 stackTrace = stackTrace, |
| 69 schedule = schedule, | 69 schedule = schedule, |
| 70 task = schedule.currentTask, | 70 task = schedule.currentTask, |
| 71 queue = schedule.currentQueue, | 71 queue = schedule.currentQueue, |
| 72 pendingCallbacks = schedule.currentQueue == null ? <String>[] | 72 pendingCallbacks = schedule.currentQueue == null ? <PendingCallback>[] |
| 73 : schedule.currentQueue.pendingCallbacks.toList(), | 73 : schedule.currentQueue.pendingCallbacks.toList(), |
| 74 _stateWhenDetected = schedule.state; | 74 _stateWhenDetected = schedule.state; |
| 75 | 75 |
| 76 bool operator ==(other) => other is ScheduleError && task == other.task && | 76 bool operator ==(other) => other is ScheduleError && task == other.task && |
| 77 queue == other.queue && _stateWhenDetected == other._stateWhenDetected && | 77 queue == other.queue && _stateWhenDetected == other._stateWhenDetected && |
| 78 error == other.error && stackTrace == other.stackTrace; | 78 error == other.error && stackTrace == other.stackTrace; |
| 79 | 79 |
| 80 String toString() { | 80 String toString() { |
| 81 var result = new StringBuffer(); | 81 var result = new StringBuffer(); |
| 82 | 82 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 105 result.write('Error detected when waiting for out-of-band callbacks in ' | 105 result.write('Error detected when waiting for out-of-band callbacks in ' |
| 106 'queue "$queue".'); | 106 'queue "$queue".'); |
| 107 } else { // _stateWhenDetected == ScheduleState.SET_UP | 107 } else { // _stateWhenDetected == ScheduleState.SET_UP |
| 108 result.write('Error detected before the schedule started running.'); | 108 result.write('Error detected before the schedule started running.'); |
| 109 } | 109 } |
| 110 | 110 |
| 111 if (!pendingCallbacks.isEmpty) { | 111 if (!pendingCallbacks.isEmpty) { |
| 112 result.write("\n\n"); | 112 result.write("\n\n"); |
| 113 result.writeln("Pending out-of-band callbacks:"); | 113 result.writeln("Pending out-of-band callbacks:"); |
| 114 for (var callback in pendingCallbacks) { | 114 for (var callback in pendingCallbacks) { |
| 115 result.writeln(prefixLines(callback, firstPrefix: "* ")); | 115 result.writeln(prefixLines(callback.toString(), firstPrefix: "* ")); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 return result.toString().trim(); | 119 return result.toString().trim(); |
| 120 } | 120 } |
| 121 } | 121 } |
| OLD | NEW |