parseError method

String? parseError(
  1. Map<String, dynamic>? body
)

Implementation

String? parseError(Map<String, dynamic>? body) {
  if (body == null) return null;

  final Object? error =
      body.containsKey('errors') ? body['errors'] : body['error'];

  if (error == null) return null;

  if (error is List<dynamic>) {
    final Map<String, dynamic> firstEntry =
        error.first as Map<String, dynamic>;
    return firstEntry['message'] as String;
  }

  if (error is String) {
    return error.contains(RegExp('ID token', caseSensitive: false))
        ? kLoginLogoutPrompt
        : error;
  }

  return null;
}