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 (26 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (2)
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
"""Exceptions raised by the ElasticSearch service."""

from moto.core.exceptions import JsonRESTError


class ElasticSearchError(JsonRESTError):
    code = 400


class ResourceNotFound(ElasticSearchError):
    code = 409

    def __init__(self, resource_type: str, resource_name: str):
        msg = f"{resource_type} not found: {resource_name}"
        super().__init__("ResourceNotFoundException", msg)


class InvalidDomainName(ElasticSearchError):
    def __init__(self, domain_name: str):
        msg = f"1 validation error detected: Value '{domain_name}' at 'domainName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-z][a-z0-9\\-]+"
        super().__init__("ValidationException", msg)


class DomainNotFound(ResourceNotFound):
    def __init__(self, domain_name: str):
        super().__init__("Domain", domain_name)