logDartError method

  1. @override
void logDartError(
  1. String? stack,
  2. String? message,
  3. String? context,
  4. String? library, {
  5. String? errorType,
  6. bool wasHandled = false,
})
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, {
  String? errorType,
  bool wasHandled = false,
}) {
  // 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,
        _errorTypeArgName: errorType,
        _errorWasHandledArgName: wasHandled,
      },
    );
  } catch (e) {
    // avoid propagating any errors that could cause an error loop!
    if (kDebugMode) {
      print('Failed to send error to Embrace: $e');
    }
  }
}