File: exceptions.py

package info (click to toggle)
python-moto 5.1.18-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 116,520 kB
  • sloc: python: 636,725; javascript: 181; makefile: 39; sh: 3
file content (115 lines) | stat: -rw-r--r-- 3,176 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"""Exceptions raised by the Directory Service service."""

from moto.core.exceptions import JsonRESTError


class DsValidationException(JsonRESTError):
    """Report one of more parameter validation errors."""

    code = 400

    def __init__(self, error_tuples: list[tuple[str, str, str]]):
        """Validation errors are concatenated into one exception message.

        error_tuples is a list of tuples.  Each tuple contains:

          - name of invalid parameter,
          - value of invalid parameter,
          - string describing the constraints for that parameter.
        """
        msg_leader = (
            f"{len(error_tuples)} "
            f"validation error{'s' if len(error_tuples) > 1 else ''} detected: "
        )
        msgs = []
        for arg_name, arg_value, constraint in error_tuples:
            value = "at" if "assword" in arg_name else f"'{arg_value}' at"
            msgs.append(
                f"Value {value} '{arg_name}' failed to satisfy constraint: "
                f"Member must {constraint}"
            )
        super().__init__("ValidationException", msg_leader + "; ".join(msgs))


class ClientException(JsonRESTError):
    """Client exception has occurred. VPC parameters are invalid."""

    code = 400

    def __init__(self, message: str):
        super().__init__("ClientException", message)


class DirectoryLimitExceededException(JsonRESTError):
    """Maximum number of directories in region has been reached."""

    code = 400

    def __init__(self, message: str):
        super().__init__("DirectoryLimitExceededException", message)


class EntityDoesNotExistException(JsonRESTError):
    """The specified entity could not be found."""

    code = 400

    def __init__(self, message: str):
        super().__init__("EntityDoesNotExistException", message)


class EntityAlreadyExistsException(JsonRESTError):
    """The specified entity already exists."""

    code = 400

    def __init__(self, message: str):
        super().__init__("EntityAlreadyExistsException", message)


class InvalidNextTokenException(JsonRESTError):
    """Invalid next token parameter used to return a list of entities."""

    code = 400

    def __init__(self) -> None:
        super().__init__(
            "InvalidNextTokenException",
            "Invalid value passed for the NextToken parameter",
        )


class InvalidParameterException(JsonRESTError):
    """Invalid parameter."""

    code = 400

    def __init__(self, message: str):
        super().__init__("InvalidParameterException", message)


class TagLimitExceededException(JsonRESTError):
    """The maximum allowed number of tags was exceeded."""

    code = 400

    def __init__(self, message: str):
        super().__init__("TagLimitExceededException", message)


class ValidationException(JsonRESTError):
    """Tag validation failed."""

    code = 400

    def __init__(self, message: str):
        super().__init__("ValidationException", message)


class UnsupportedOperationException(JsonRESTError):
    """Unsupported Operation"""

    code = 400

    def __init__(self, message: str):
        super().__init__("UnsupportedOperationException", message)