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 | | |
|
9 | | | class TaskCanceledException implements SquadronError, CanceledException { |
10 | | 2 | TaskCanceledException(String? message) : message = message ?? 'Task canceled'; |
11 | | |
|
12 | | | @override |
13 | | | final String message; |
14 | | |
|
15 | | 0 | @override |
16 | | | StackTrace? get stackTrace => null; |
17 | | |
|
18 | | 0 | @override |
19 | | 0 | String toString() => jsonEncode(serialize()); |
20 | | |
|
21 | | 0 | @override |
22 | | 0 | List serialize() => List.unmodifiable([$taskCanceledExceptionType, message]); |
23 | | | } |
24 | | |
|
25 | | | const _$type = 0; |
26 | | | const _$message = 1; |
27 | | |
|
28 | | | @internal |
29 | | | extension TaskCanceledExceptionExt on TaskCanceledException { |
30 | | 0 | static TaskCanceledException? deserialize(List? props) { |
31 | | | if (props == null) return null; |
32 | | 0 | if (props[_$type] != $taskCanceledExceptionType) return null; |
33 | | 0 | return TaskCanceledException(props[_$message]); |
34 | | | } |
35 | | | } |