1 | | | import 'dart:async'; |
2 | | |
|
3 | | | import 'package:cancelation_token/cancelation_token.dart'; |
4 | | | import 'package:meta/meta.dart'; |
5 | | |
|
6 | | | import 'squadron_canceled_exception.dart'; |
7 | | | import 'squadron_exception.dart'; |
8 | | | import 'squadron_timeout_exception.dart'; |
9 | | |
|
10 | | | const $squadronErrorType = '\$sqdrn'; |
11 | | | const $workerExceptionType = '\$wrkr'; |
12 | | | const $canceledExceptionType = '\$cncld'; |
13 | | | const $canceledExceptionsType = '\$cncld*'; |
14 | | | const $timeoutExceptionType = '\$tmt'; |
15 | | |
|
16 | | | const $reservedExceptionTypeIds = { |
17 | | | $squadronErrorType, |
18 | | | $workerExceptionType, |
19 | | | $canceledExceptionType, |
20 | | | $canceledExceptionsType, |
21 | | | $timeoutExceptionType, |
22 | | | }; |
23 | | |
|
24 | | | @internal |
25 | | | extension CanceledConversionExt on CanceledException { |
26 | | 2 | SquadronException toSquadronException( |
27 | | | [String? tokenId, StackTrace? stackTrace]) => |
28 | | 2 | SquadronCanceledException.from( |
29 | | | tokenId ?? '', |
30 | | | this, |
31 | | | stackTrace, |
32 | | | ); |
33 | | | } |
34 | | |
|
35 | | | @internal |
36 | | | extension TimeoutConversionExt on TimeoutException { |
37 | | 2 | SquadronException toSquadronException( |
38 | | | [String? tokenId, StackTrace? stackTrace]) => |
39 | | 2 | SquadronTimeoutException( |
40 | | | tokenId ?? '', |
41 | | 2 | message ?? 'Operation timeout', |
42 | | 2 | duration, |
43 | | | stackTrace, |
44 | | | ); |
45 | | | } |