lobstr.exceptions.LobstersError

Bases: Exception

Base exception for the lobste.rs client.

Source code in lobstr/exceptions.py
6
7
class LobstersError(Exception):
    """Base exception for the lobste.rs client."""

lobstr.exceptions.LobstersAPIError

Bases: LobstersError

Base exception for API-related failures.

Source code in lobstr/exceptions.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class LobstersAPIError(LobstersError):
    """Base exception for API-related failures."""

    def __init__(
        self,
        *,
        resource: str,
        identifier: str | int,
        endpoint: URL,
        status_code: int,
    ) -> None:
        self.identifier = identifier
        self.endpoint = endpoint
        self.status_code = status_code

        identifier_repr = (
            repr(identifier) if isinstance(identifier, str) else str(identifier)
        )

        super().__init__(
            f"{resource} {identifier_repr} not found "
            f"(GET {endpoint} returned {status_code})"
        )

lobstr.exceptions.ResourceNotFound

Bases: LobstersAPIError

Base exception for missing Lobsters resources.

Source code in lobstr/exceptions.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class ResourceNotFound(LobstersAPIError):
    """Base exception for missing Lobsters resources."""

    resource_name = "Resource"
    status_code = 404

    def __init__(
        self,
        identifier: str | int,
        *,
        endpoint: URL,
    ) -> None:
        super().__init__(
            resource=self.resource_name,
            identifier=identifier,
            endpoint=endpoint,
            status_code=self.status_code,
        )

lobstr.exceptions.StoryNotFound

Bases: ResourceNotFound

Source code in lobstr/exceptions.py
55
56
57
58
59
60
61
62
63
class StoryNotFound(ResourceNotFound):
    resource_name = "Story"

    def __init__(self, story_id: str, *, endpoint: URL) -> None:
        self.story_id = story_id
        super().__init__(
            identifier=story_id,
            endpoint=endpoint,
        )

lobstr.exceptions.CommentNotFound

Bases: ResourceNotFound

Source code in lobstr/exceptions.py
66
67
68
69
70
71
72
73
74
75
class CommentNotFound(ResourceNotFound):
    resource_name = "Comment"
    status_code = 400

    def __init__(self, comment_id: str, *, endpoint: URL) -> None:
        self.comment_id = comment_id
        super().__init__(
            identifier=comment_id,
            endpoint=endpoint,
        )

lobstr.exceptions.UserNotFound

Bases: ResourceNotFound

Source code in lobstr/exceptions.py
78
79
80
81
82
83
84
85
86
class UserNotFound(ResourceNotFound):
    resource_name = "User"

    def __init__(self, username: str, *, endpoint: URL) -> None:
        self.username = username
        super().__init__(
            identifier=username,
            endpoint=endpoint,
        )

lobstr.exceptions.TagNotFound

Bases: ResourceNotFound

Source code in lobstr/exceptions.py
89
90
91
92
93
94
95
96
97
class TagNotFound(ResourceNotFound):
    resource_name = "Tag"

    def __init__(self, tag: str, *, endpoint: URL) -> None:
        self.tag = tag
        super().__init__(
            identifier=tag,
            endpoint=endpoint,
        )

lobstr.exceptions.FeedPageNotFound

Bases: ResourceNotFound

Source code in lobstr/exceptions.py
100
101
102
103
104
105
106
107
108
class FeedPageNotFound(ResourceNotFound):
    resource_name = "Feed page"

    def __init__(self, page: int, *, endpoint: URL) -> None:
        self.page = page
        super().__init__(
            identifier=page,
            endpoint=endpoint,
        )