FirebaseMessagingAdminException.fromServerError constructor

  1. @internal
FirebaseMessagingAdminException.fromServerError({
  1. required String serverErrorCode,
  2. String? message,
  3. Object? rawServerResponse,
})

Implementation

@internal
factory FirebaseMessagingAdminException.fromServerError({
  required String serverErrorCode,
  String? message,
  Object? rawServerResponse,
}) {
  // If not found, default to unknown error.
  final error = messagingServerToClientCode[serverErrorCode] ??
      MessagingClientErrorCode.unknownError;
  message ??= error.message;

  if (error == MessagingClientErrorCode.unknownError &&
      rawServerResponse != null) {
    try {
      message += ' Raw server response: "${jsonEncode(rawServerResponse)}"';
    } catch (e) {
      // Ignore JSON parsing error.
    }
  }

  return FirebaseMessagingAdminException(error, message);
}