FirebaseMessagingAdminException.fromTopicManagementServerError constructor

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

Implementation

@internal
factory FirebaseMessagingAdminException.fromTopicManagementServerError({
  required String serverErrorCode,
  String? message,
  Object? rawServerResponse,
}) {
  // If not found, default to unknown error.
  final clientCodeKey =
      _topicMgtServerToClientCode[serverErrorCode] ?? 'UNKNOWN_ERROR';
  final error = MessagingClientErrorCode.fromCode(clientCodeKey);
  message ??= error.message;

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

  return FirebaseMessagingAdminException(error, message);
}