| 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 29 matching lines...) Expand all Loading... |
| 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, |
| 47 {StackTrace stackTrace}) { | 47 {StackTrace stackTrace}) { |
| 48 if (error is ScheduleError) return error; | 48 if (error is ScheduleError) return error; |
| 49 | 49 |
| 50 var attachedTrace = getAttachedStackTrace(error); | 50 if (stackTrace == null && error is Error) { |
| 51 if (attachedTrace != null) { | |
| 52 // Overwrite the explicit stack trace, because it probably came from a | 51 // Overwrite the explicit stack trace, because it probably came from a |
| 53 // rethrow in the first place. | 52 // rethrow in the first place. |
| 54 stackTrace = attachedTrace; | 53 stackTrace = error.stackTrace; |
| 55 } | 54 } |
| 56 | 55 |
| 57 if (stackTrace == null) stackTrace = new Trace.current(); | 56 if (stackTrace == null) stackTrace = new Trace.current(); |
| 58 return new ScheduleError(schedule, error, stackTrace); | 57 return new ScheduleError(schedule, error, stackTrace); |
| 59 } | 58 } |
| 60 | 59 |
| 61 // TODO(floitsch): restore StackTrace type when it has been integrated into | 60 // TODO(floitsch): restore StackTrace type when it has been integrated into |
| 62 // the core libraries. | 61 // the core libraries. |
| 63 ScheduleError(Schedule schedule, error, var stackTrace) | 62 ScheduleError(Schedule schedule, error, var stackTrace) |
| 64 : error = error, | 63 : error = error, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 result.write("\n\n"); | 108 result.write("\n\n"); |
| 110 result.writeln("Pending out-of-band callbacks:"); | 109 result.writeln("Pending out-of-band callbacks:"); |
| 111 for (var callback in pendingCallbacks) { | 110 for (var callback in pendingCallbacks) { |
| 112 result.writeln(prefixLines(callback.toString(), firstPrefix: "* ")); | 111 result.writeln(prefixLines(callback.toString(), firstPrefix: "* ")); |
| 113 } | 112 } |
| 114 } | 113 } |
| 115 | 114 |
| 116 return result.toString().trim(); | 115 return result.toString().trim(); |
| 117 } | 116 } |
| 118 } | 117 } |
| OLD | NEW |