| 1 | | | import 'package:meta/meta.dart'; |
| 2 | | | |
| 3 | | | import '_builtin_exceptions.dart'; |
| 4 | | | import 'squadron_exception.dart'; |
| 5 | | | |
| 6 | | | /// Squadron Error |
| 7 | | | class SquadronError extends SquadronException { |
| 8 | | 11 | SquadronError._(super.message, [super.stackTrace, int? command]) |
| 9 | | | : _command = command, |
| 10 | | 11 | super.init(); |
| 11 | | | |
| 12 | | | final int? _command; |
| 13 | | | |
| 14 | | 2 | @override |
| 15 | | 4 | List serialize() => List.unmodifiable([ |
| 16 | | | $squadronErrorType, |
| 17 | | 2 | message, |
| 18 | | 4 | stackTrace?.toString(), |
| 19 | | 2 | _command, |
| 20 | | | ]); |
| 21 | | | } |
| 22 | | | |
| 23 | | | const _$type = 0; |
| 24 | | | const _$message = 1; |
| 25 | | | const _$stackTrace = 2; |
| 26 | | | const _$command = 3; |
| 27 | | | |
| 28 | | | @internal |
| 29 | | | extension SquadronErrorImpl on SquadronError { |
| 30 | | 11 | static SquadronError create(String message, |
| 31 | | | [StackTrace? stackTrace, int? command]) => |
| 32 | | 11 | SquadronError._(message, stackTrace, command); |
| 33 | | | |
| 34 | | 2 | static SquadronException? deserialize(List exceptionInfo) => |
| 35 | | 4 | (exceptionInfo[_$type] == $squadronErrorType) |
| 36 | | 2 | ? SquadronError._( |
| 37 | | 2 | exceptionInfo[_$message], |
| 38 | | 4 | SquadronException.loadStackTrace(exceptionInfo[_$stackTrace]), |
| 39 | | 2 | exceptionInfo[_$command], |
| 40 | | | ) |
| 41 | | | : null; |
| 42 | | | } |