recordCrash function
Records an error and stack trace for crash reporting.
This function is used internally by the SDK for automatic crash reporting.
Implementation
Future<void> recordCrash(Object error, StackTrace stackTrace) async {
try {
final callStacks = _parseStackTrace(stackTrace);
final exceptionRecord = _ExceptionRecord(
type: error.runtimeType.toString(),
message: error.toString(),
callStacks: callStacks,
);
final Map<String, dynamic> errorData = {
'exceptions': [exceptionRecord.toMap()],
'flutterSdkVersion': nativebrikFlutterSdkVersion,
};
await NativebrikBridgePlatform.instance.recordCrash(errorData);
} catch (e) {
// Silently handle any errors in the crash reporting itself
debugPrint('[CrashReport] Error recording crash: $e');
}
}