FirebaseAuthAdminException.fromServerError constructor
FirebaseAuthAdminException.fromServerError({})
Implementation
factory FirebaseAuthAdminException.fromServerError({
required String serverErrorCode,
Object? rawServerResponse,
}) {
// serverErrorCode could contain additional details:
// ERROR_CODE : Detailed message which can also contain colons
final colonSeparator = serverErrorCode.indexOf(':');
String? customMessage;
if (colonSeparator != -1) {
customMessage = serverErrorCode.substring(colonSeparator + 1).trim();
serverErrorCode = serverErrorCode.substring(0, colonSeparator).trim();
}
// If not found, default to internal error.
final error = authServerToClientCode[serverErrorCode] ??
AuthClientErrorCode.internalError;
// Server detailed message should have highest priority.
customMessage = customMessage ?? error.message;
if (error == AuthClientErrorCode.internalError &&
rawServerResponse != null) {
try {
customMessage +=
' Raw server response: "${jsonEncode(rawServerResponse)}"';
} catch (e) {
// Ignore JSON parsing error.
}
}
return FirebaseAuthAdminException(error, customMessage);
}