convertFirebaseFunctionsException function Null safety

FirebaseFunctionsException convertFirebaseFunctionsException(
  1. Object exception,
  2. [StackTrace? stackTrace]
)

Given a web error, a FirebaseFunctionsException is returned.

Implementation

FirebaseFunctionsException convertFirebaseFunctionsException(Object exception,
    [StackTrace? stackTrace]) {
  String originalCode = util.getProperty(exception, 'code');
  String code = originalCode.replaceFirst('functions/', '');
  String message = util
      .getProperty(exception, 'message')
      .replaceFirst('($originalCode)', '');

  return FirebaseFunctionsException(
      code: code,
      message: message,
      stackTrace: stackTrace,
      details: dartify(util.getProperty(exception, 'details')));
}