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 (35 lines) | stat: -rw-r--r-- 1,234 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
"""Exceptions raised by the comprehend service."""

from moto.core.exceptions import JsonRESTError


class ResourceNotFound(JsonRESTError):
    def __init__(self) -> None:
        super().__init__(
            "ResourceNotFoundException",
            "RESOURCE_NOT_FOUND: Could not find specified resource.",
        )


class DetectPIIValidationException(JsonRESTError):
    def __init__(self, language: str, all_languages: list[str]) -> None:
        all_languages_str = str(all_languages).replace("'", "")
        super().__init__(
            "ValidationException",
            f"Value '{language}' at 'languageCode'failed to satisfy constraint: "
            f"Member must satisfy enum value set: {all_languages_str}",
        )


class TextSizeLimitExceededException(JsonRESTError):
    def __init__(self, size: int) -> None:
        super().__init__(
            "TextSizeLimitExceededException",
            "Input text size exceeds limit. Max length of request text allowed is 100000 bytes while in "
            f"this request the text size is {size} bytes",
        )


class InvalidRequestException(JsonRESTError):
    def __init__(self, message: str) -> None:
        super().__init__("InvalidRequestException", message)