getRecord method

Future<MealRecordModel> getRecord(
  1. {required String mealRecordId}
)

Implementation

Future<MealRecordModel> getRecord({required String mealRecordId}) async {
  try {
    final result = await _client.getMealRecord(mealRecordId: mealRecordId);
    final resultData = result.data;

    if (resultData == null) {
      throw RepositoryException(
        RepositoryErrorType.notFound,
        RepositoryErrorType.notFound.message,
      );
    }

    final mealRecord = _convertToMealRecordDto.exec(
      mealRecord: resultData,
    );

    return mealRecord;
  } on RepositoryException catch (_) {
    rethrow;
  } on DioException catch (error, stackTrace) {
    throw await _dioErrorHandler.handleDioError(
      error,
      stackTrace,
      mealRecordId,
    );
  } catch (error, stackTrace) {
    throw _repositoryErrorHandler.handleUnknownError(error, stackTrace);
  }
}