# -*- coding: utf-8 -*-
from __future__ import annotations

import logging
import uuid

from django.http import Http404

from hotpocket_soa.dto.saves import SaveOut
from hotpocket_soa.services import SavesService

LOGGER = logging.getLogger(__name__)


class UISavesService:
    def __init__(self):
        self.saves_service = SavesService()

    def get_or_404(self, *, pk: uuid.UUID) -> SaveOut:
        try:
            return SavesService().get(pk=pk)
        except SavesService.NotFound as exception:
            LOGGER.error(
                'Save not found: pk=`%s`', pk, exc_info=exception,
            )
            raise Http404()
