serialize static method
- dynamic error,
- StackTrace stackTrace
Serializes error
and stackTrace
into a JSON-safe object.
Other than JSON- and isolate-safety, no guarantees are made about the serialized format.
Implementation
static Map<String, dynamic> serialize(dynamic error, StackTrace stackTrace) {
String? message;
if (error is String) {
message = error;
} else {
try {
message = error.message.toString();
} on NoSuchMethodError catch (_) {
// Do nothing.
}
}
final supertype = (error is TestFailure) ? 'TestFailure' : null;
return {
'message': message,
'type': error.runtimeType.toString(),
'supertype': supertype,
'toString': error.toString(),
'stackChain': Chain.forTrace(stackTrace).toString()
};
}