1 | | | import 'dart:convert'; |
2 | | |
|
3 | | | import 'package:cancelation_token/cancelation_token.dart'; |
4 | | | import 'package:meta/meta.dart'; |
5 | | |
|
6 | | | import '_well_known_exceptions.dart'; |
7 | | | import 'squadron_canceled_exception.dart'; |
8 | | |
|
9 | | | class SquadronCanceledExceptions extends SquadronCanceledException |
10 | | | implements CanceledExceptions { |
11 | | 2 | SquadronCanceledExceptions( |
12 | | | String tokenId, Iterable<SquadronCanceledException> exceptions) |
13 | | 2 | : _exceptions = exceptions.toList(), |
14 | | 2 | super(tokenId, '', null); |
15 | | |
|
16 | | | final List<SquadronCanceledException> _exceptions; |
17 | | |
|
18 | | 0 | @override |
19 | | 0 | Iterable<CanceledException> get innerExceptions => _exceptions; |
20 | | |
|
21 | | 0 | @override |
22 | | 0 | String get message => _exceptions.map((e) => e.message).join('\n'); |
23 | | |
|
24 | | 0 | @override |
25 | | 0 | StackTrace? get stackTrace => null; |
26 | | |
|
27 | | 0 | @override |
28 | | 0 | String toString() => jsonEncode(serialize()); |
29 | | |
|
30 | | 1 | @override |
31 | | 3 | List serialize() => List.unmodifiable([ |
32 | | | $canceledExceptionsType, |
33 | | 2 | tokenId, |
34 | | 16 | _exceptions.map((e) => e.serialize()).toList(), |
35 | | 1 | ]); |
36 | | | } |
37 | | |
|
38 | | | const _$type = 0; |
39 | | | const _$tokenId = 1; |
40 | | | const _$innerExceptions = 2; |
41 | | |
|
42 | | | @internal |
43 | | | extension SquadronCanceledExceptionsExt on SquadronCanceledExceptions { |
44 | | 1 | static SquadronCanceledExceptions? deserialize(List? props) { |
45 | | 0 | if (props == null) return null; |
46 | | 2 | if (props[_$type] != $canceledExceptionsType) return null; |
47 | | 0 | return SquadronCanceledExceptions( |
48 | | 1 | props[_$tokenId], |
49 | | 2 | props[_$innerExceptions].map(SquadronCanceledExceptionExt.deserialize), |
50 | | | ); |
51 | | 0 | } |
52 | | | } |