recordError function
Future<void>
recordError(
- Object error,
- StackTrace stackTrace, {
- ErrorSeverity severity = ErrorSeverity.crash,
Records an error with stack trace at the specified severity level.
error: The error object to recordstackTrace: The stack trace associated with the errorseverity: The severity level (defaults to ErrorSeverity.crash)
Implementation
Future<void> recordError(
Object error,
StackTrace stackTrace, {
ErrorSeverity severity = ErrorSeverity.crash,
}) async {
try {
final exceptionRecord = _ExceptionRecord(
type: error.runtimeType.toString(),
message: error.toString(),
callStacks: _parseStackTrace(stackTrace),
);
final Map<String, dynamic> errorData = {
'exceptions': [exceptionRecord.toMap()],
'flutterSdkVersion': nativebrikFlutterSdkVersion,
'severity': severity.name,
};
await NativebrikBridgePlatform.instance.recordCrash(errorData);
} catch (e) {
// Silently handle any errors in the crash reporting itself
}
}