| 1 | | | import 'dart:convert'; |
| 2 | | | |
| 3 | | | import 'package:cancelation_token/cancelation_token.dart'; |
| 4 | | | import 'package:meta/meta.dart'; |
| 5 | | | |
| 6 | | | import '_builtin_exceptions.dart'; |
| 7 | | | import 'squadron_error.dart'; |
| 8 | | | import 'squadron_exception.dart'; |
| 9 | | | |
| 10 | | | class TaskTerminatedException implements SquadronError, CanceledException { |
| 11 | | 2 | TaskTerminatedException(this.message, [this.stackTrace]); |
| 12 | | | |
| 13 | | | @override |
| 14 | | | final String message; |
| 15 | | | |
| 16 | | | @override |
| 17 | | | final StackTrace? stackTrace; |
| 18 | | | |
| 19 | | 0 | @override |
| 20 | | 0 | String toString() => jsonEncode(serialize()); |
| 21 | | | |
| 22 | | 0 | @override |
| 23 | | 0 | List serialize() => List.unmodifiable( |
| 24 | | 0 | [$taskTerminatedExceptionType, message, stackTrace?.toString()]); |
| 25 | | | } |
| 26 | | | |
| 27 | | | const _$type = 0; |
| 28 | | | const _$message = 1; |
| 29 | | | const _$stackTrace = 2; |
| 30 | | | |
| 31 | | | @internal |
| 32 | | | extension TaskTerminatedExceptionExt on TaskTerminatedException { |
| 33 | | 0 | static TaskTerminatedException? deserialize(List? props) { |
| 34 | | | if (props == null) return null; |
| 35 | | 0 | if (props[_$type] != $taskTerminatedExceptionType) return null; |
| 36 | | 0 | return TaskTerminatedException( |
| 37 | | 0 | props[_$message], |
| 38 | | 0 | SquadronException.loadStackTrace(props[_$stackTrace]), |
| 39 | | | ); |
| 40 | | | } |
| 41 | | | } |