1 | | | import 'package:cancelation_token/cancelation_token.dart'; |
2 | | | import 'package:meta/meta.dart'; |
3 | | |
|
4 | | | import '_well_known_exceptions.dart'; |
5 | | | import 'squadron_canceled_exception.dart'; |
6 | | | import 'squadron_exception.dart'; |
7 | | |
|
8 | | | class SquadronTimeoutException extends SquadronCanceledException |
9 | | | implements TimeoutCanceledException { |
10 | | 6 | SquadronTimeoutException(String tokenId, String message, this.duration, |
11 | | | [StackTrace? stackTrace]) |
12 | | 6 | : super(tokenId, message, stackTrace); |
13 | | |
|
14 | | | @override |
15 | | | final Duration? duration; |
16 | | |
|
17 | | 3 | @override |
18 | | 7 | List serialize() => List.unmodifiable([ |
19 | | | $timeoutExceptionType, |
20 | | 4 | tokenId, |
21 | | 4 | message, |
22 | | 7 | stackTrace?.toString(), |
23 | | 4 | duration?.inMicroseconds, |
24 | | 1 | ]); |
25 | | | } |
26 | | |
|
27 | | | const _$type = 0; |
28 | | | const _$tokenId = 1; |
29 | | | const _$message = 2; |
30 | | | const _$stackTrace = 3; |
31 | | | const _$duration = 4; |
32 | | |
|
33 | | | @internal |
34 | | | extension SquadronTimeoutExceptionExt on SquadronTimeoutException { |
35 | | 5 | static SquadronTimeoutException? deserialize(List? props) { |
36 | | 2 | if (props == null) return null; |
37 | | 8 | if (props[_$type] != $timeoutExceptionType) return null; |
38 | | 5 | final microSecs = (props[_$duration] as num?)?.toInt(); |
39 | | 5 | return SquadronTimeoutException( |
40 | | 5 | props[_$tokenId], |
41 | | 5 | props[_$message], |
42 | | 2 | (microSecs == null) ? null : Duration(microseconds: microSecs), |
43 | | 8 | SquadronException.loadStackTrace(props[_$stackTrace]), |
44 | | | ); |
45 | | 2 | } |
46 | | | } |