| 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_canceled_exception.dart'; |
| 8 | | | |
| 9 | | | class SquadronCanceledExceptions extends SquadronCanceledException |
| 10 | | | implements CanceledExceptions { |
| 11 | | 1 | SquadronCanceledExceptions( |
| 12 | | | String tokenId, Iterable<SquadronCanceledException> exceptions) |
| 13 | | 1 | : _exceptions = exceptions.toList(), |
| 14 | | 1 | 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 | | | StackTrace? get stackTrace => null; |
| 26 | | | |
| 27 | | 0 | @override |
| 28 | | 0 | String toString() => jsonEncode(serialize()); |
| 29 | | | |
| 30 | | 1 | @override |
| 31 | | 2 | List serialize() => List.unmodifiable([ |
| 32 | | | $canceledExceptionsType, |
| 33 | | 1 | tokenId, |
| 34 | | 5 | _exceptions.map((e) => e.serialize()).toList(), |
| 35 | | | ]); |
| 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 | | | 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 | | | } |
| 52 | | | } |