aboutsummaryrefslogtreecommitdiff
path: root/markov/errors.py
blob: 875d3b7dc0eb797ebcc2b2ab70bbd614523e2f64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class MarkovGenerationError(Exception):
    def __init__(self, guild_id: int, member_id: int | None):
        self.guild_id = guild_id
        self.member_id = member_id

    def __repr__(self):
        return f"MarkovGenerationError(guild_id={self.guild_id}, member_id={self.member_id})"


class NoTotalCompletionCountError(MarkovGenerationError):
    def __init__(self, guild_id: int, member_id: int | None, token: str):
        super().__init__(guild_id, member_id)
        self.token = token

    def __repr__(self):
        return (
            "NoTotalCompletionCountError(guild_id={}, member_id={}, token={})".format(
                self.guild_id, self.member_id, repr(self.token)
            )
        )


class NoNextTokenError(MarkovGenerationError):
    def __init__(self, guild_id: int, member_id: int | None, token: str, offset: int):
        super().__init__(guild_id, member_id)
        self.token = token
        self.offset = offset

    def __repr__(self):
        return (
            "NoNextTokenError(guild_id={}, member_id={}, token={}, offset={})".format(
                self.guild_id, self.member_id, repr(self.token), self.offset
            )
        )


class InvalidCompletionCountError(MarkovGenerationError):
    def __init__(self, guild_id: int, member_id: int | None, token: str, offset: int):
        super().__init__(guild_id, member_id)
        self.token = token
        self.offset = offset

    def __repr__(self):
        return "InvalidCompletionCountError(guild_id={}, member_id={}, token={}, offset={})".format(
            self.guild_id, self.member_id, repr(self.token), self.offset
        )