convertPlatformExceptionToFirebaseException function

Never convertPlatformExceptionToFirebaseException(
  1. Object exception,
  2. StackTrace rawStackTrace, {
  3. required String plugin,
})

Catches a PlatformException and returns an Exception.

If the Exception is a PlatformException, a FirebaseException is returned.

Implementation

Never convertPlatformExceptionToFirebaseException(
  Object exception,
  StackTrace rawStackTrace, {
  required String plugin,
}) {
  var stackTrace = rawStackTrace;
  if (stackTrace == StackTrace.empty) {
    stackTrace = StackTrace.current;
  }

  if (exception is! PlatformException) {
    Error.throwWithStackTrace(exception, stackTrace);
  }

  Error.throwWithStackTrace(
    platformExceptionToFirebaseException(exception, plugin: plugin),
    stackTrace,
  );
}