logDartError method

  1. @override
void logDartError(
  1. String? stack,
  2. String? message,
  3. String? context,
  4. String? library,
)
override

Sends information from a Dart error/exception to the host SDK so that a log can be delivered.

Implementation

@override
void logDartError(
  String? stack,
  String? message,
  String? context,
  String? library,
) {
  // return silently instead of throwing a StateError - as throwing an
  // exception during exception handling would likely cause an error loop.
  if (!isStarted) {
    return;
  }

  try {
    methodChannel.invokeMethod(
      _logDartErrorMethodName,
      {
        _errorStackArgName: stack,
        _errorMessageArgName: message,
        _errorContextArgName: context,
        _errorLibraryArgName: library
      },
    );
  } catch (e) {
    // avoid propagating any errors that could cause an error loop!
    if (kDebugMode) {
      print('Failed to send error to Embrace: $e');
    }
  }
}