| 1 |  |  | import 'package:cancelation_token/cancelation_token.dart'; | 
                
                
                    | 2 |  |  | import 'package:meta/meta.dart'; | 
                
                
                    | 3 |  |  |  | 
                
                
                    | 4 |  |  | import '_builtin_exceptions.dart'; | 
                
                
                    | 5 |  |  | import 'squadron_canceled_exceptions.dart'; | 
                
                
                    | 6 |  |  | import 'squadron_exception.dart'; | 
                
                
                    | 7 |  |  | import 'squadron_timeout_exception.dart'; | 
                
                
                    | 8 |  |  |  | 
                
                
                    | 9 |  |  | class SquadronCanceledException extends SquadronException | 
                
                
                    | 10 |  |  |     implements CanceledException { | 
                
                
                    | 11 |  | 3 |   SquadronCanceledException( | 
                
                
                    | 12 |  |  |       this.tokenId, String message, StackTrace? stackTrace) | 
                
                
                    | 13 |  | 3 |       : super.init(message, stackTrace); | 
                
                
                    | 14 |  |  |  | 
                
                
                    | 15 |  | 3 |   factory SquadronCanceledException.from(String tokenId, CanceledException ex, | 
                
                
                    | 16 |  |  |       [StackTrace? stackTrace]) { | 
                
                
                    | 17 |  | 3 |     if (ex is TimeoutCanceledException) { | 
                
                
                    | 18 |  | 1 |       return SquadronTimeoutException( | 
                
                
                    | 19 |  | 3 |           tokenId, ex.message, ex.duration, ex.stackTrace); | 
                
                
                    | 20 |  | 3 |     } else if (ex is CanceledExceptions) { | 
                
                
                    | 21 |  | 1 |       return SquadronCanceledExceptions( | 
                
                
                    | 22 |  |  |         tokenId, | 
                
                
                    | 23 |  | 2 |         ex.innerExceptions.map( | 
                
                
                    | 24 |  | 3 |           (e) => SquadronCanceledException.from(tokenId, e, e.stackTrace), | 
                
                
                    | 25 |  |  |         ), | 
                
                
                    | 26 |  |  |       ); | 
                
                
                    | 27 |  |  |     } else { | 
                
                
                    | 28 |  | 9 |       return SquadronCanceledException(tokenId, ex.message, ex.stackTrace); | 
                
                
                    | 29 |  |  |     } | 
                
                
                    | 30 |  |  |   } | 
                
                
                    | 31 |  |  |  | 
                
                
                    | 32 |  |  |   final String tokenId; | 
                
                
                    | 33 |  |  |  | 
                
                
                    | 34 |  | 3 |   @override | 
                
                
                    | 35 |  | 6 |   List serialize() => List.unmodifiable([ | 
                
                
                    | 36 |  |  |         $canceledExceptionType, | 
                
                
                    | 37 |  | 3 |         tokenId, | 
                
                
                    | 38 |  | 3 |         message, | 
                
                
                    | 39 |  | 6 |         stackTrace?.toString(), | 
                
                
                    | 40 |  |  |       ]); | 
                
                
                    | 41 |  |  | } | 
                
                
                    | 42 |  |  |  | 
                
                
                    | 43 |  |  | const _$type = 0; | 
                
                
                    | 44 |  |  | const _$tokenId = 1; | 
                
                
                    | 45 |  |  | const _$message = 2; | 
                
                
                    | 46 |  |  | const _$stackTrace = 3; | 
                
                
                    | 47 |  |  |  | 
                
                
                    | 48 |  |  | @internal | 
                
                
                    | 49 |  |  | extension SquadronCanceledExceptionExt on SquadronCanceledException { | 
                
                
                    | 50 |  | 3 |   static SquadronCanceledException? deserialize(List? props) { | 
                
                
                    | 51 |  |  |     if (props == null) return null; | 
                
                
                    | 52 |  | 3 |     switch (props[_$type]) { | 
                
                
                    | 53 |  | 3 |       case $canceledExceptionType: | 
                
                
                    | 54 |  | 3 |         return SquadronCanceledException( | 
                
                
                    | 55 |  | 3 |           props[_$tokenId], | 
                
                
                    | 56 |  | 3 |           props[_$message], | 
                
                
                    | 57 |  | 6 |           SquadronException.loadStackTrace(props[_$stackTrace]), | 
                
                
                    | 58 |  |  |         ); | 
                
                
                    | 59 |  | 1 |       case $canceledExceptionsType: | 
                
                
                    | 60 |  | 1 |         return SquadronCanceledExceptionsExt.deserialize(props); | 
                
                
                    | 61 |  | 1 |       case $timeoutExceptionType: | 
                
                
                    | 62 |  | 1 |         return SquadronTimeoutExceptionExt.deserialize(props); | 
                
                
                    | 63 |  |  |       default: | 
                
                
                    | 64 |  |  |         return null; | 
                
                
                    | 65 |  |  |     } | 
                
                
                    | 66 |  |  |   } | 
                
                
                    | 67 |  |  | } |