MeiliSearchApiException.fromHttpBody constructor

MeiliSearchApiException.fromHttpBody(
  1. String message,
  2. Object? httpBody
)

Implementation

factory MeiliSearchApiException.fromHttpBody(
  String message,
  Object? httpBody,
) {
  if (httpBody != null &&
      httpBody is Map<String, Object?> &&
      httpBody.containsKey('message') &&
      httpBody.containsKey('code') &&
      httpBody.containsKey('link') &&
      httpBody.containsKey('type')) {
    return MeiliSearchApiException(
      httpBody['message'] as String? ?? "",
      code: httpBody['code'] as String?,
      link: httpBody['link'] as String?,
      type: httpBody['type'] as String?,
    );
  } else {
    return MeiliSearchApiException(message);
  }
}