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