Skip to content

Commit d80b05d

Browse files
author
Raphael Krupinski
committed
Raise ResultGetError for missing value.
1 parent 9f39a40 commit d80b05d

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

taskiq_nats/exceptions.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

taskiq_nats/result_backend.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
from nats.js import JetStreamContext
66
from nats.js.errors import BucketNotFoundError, ObjectNotFoundError
77
from nats.js.object_store import ObjectStore
8-
from taskiq import AsyncResultBackend
8+
from taskiq import AsyncResultBackend, ResultGetError
99
from taskiq.abc.serializer import TaskiqSerializer
1010
from taskiq.compat import model_dump, model_validate
1111
from taskiq.result import TaskiqResult
1212
from taskiq.serializers import PickleSerializer
1313

14-
from taskiq_nats.exceptions import ResultIsMissingError
15-
1614
_ReturnType = TypeVar("_ReturnType")
1715

1816

@@ -109,7 +107,7 @@ async def get_result(
109107
name=task_id,
110108
)
111109
except ObjectNotFoundError as exc:
112-
raise ResultIsMissingError from exc
110+
raise ResultGetError from exc
113111

114112
if not self.keep_results:
115113
await self.object_store.delete(

tests/test_result_backend.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
from typing import Any, List, TypeVar
33

44
import pytest
5-
from taskiq import TaskiqResult
5+
from taskiq import ResultGetError, TaskiqResult
66

77
from taskiq_nats import NATSObjectStoreResultBackend
8-
from taskiq_nats.exceptions import ResultIsMissingError
98

109
_ReturnType = TypeVar("_ReturnType")
1110
pytestmark = pytest.mark.anyio
@@ -64,7 +63,7 @@ async def test_failure_backend_result(
6463
task_id: str,
6564
) -> None:
6665
"""Test exception raising in `get_result` method."""
67-
with pytest.raises(expected_exception=ResultIsMissingError):
66+
with pytest.raises(expected_exception=ResultGetError):
6867
await nats_result_backend.get_result(task_id=task_id)
6968

7069

@@ -85,7 +84,7 @@ async def test_success_backend_default_result_delete_res(
8584
)
8685
await backend.get_result(task_id=task_id)
8786

88-
with pytest.raises(expected_exception=ResultIsMissingError):
87+
with pytest.raises(expected_exception=ResultGetError):
8988
await backend.get_result(task_id=task_id)
9089

9190
await backend.shutdown()

0 commit comments

Comments
 (0)