File: exceptions.py

package info (click to toggle)
python-openapi-core 0.19.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,008 kB
  • sloc: python: 18,868; makefile: 47
file content (54 lines) | stat: -rw-r--r-- 1,268 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
from dataclasses import dataclass
from typing import Any
from typing import Dict
from typing import Iterable

from openapi_core.exceptions import OpenAPIError
from openapi_core.validation.exceptions import ValidationError
from openapi_core.validation.schemas.exceptions import ValidateError


@dataclass
class HeadersError(Exception):
    headers: Dict[str, Any]
    context: Iterable[OpenAPIError]


class ResponseValidationError(ValidationError):
    """Response error"""


class DataValidationError(ResponseValidationError):
    """Data error"""


class InvalidData(DataValidationError, ValidateError):
    """Invalid data"""


class MissingData(DataValidationError):
    def __str__(self) -> str:
        return "Missing response data"


@dataclass
class HeaderValidationError(ResponseValidationError):
    name: str


class InvalidHeader(HeaderValidationError, ValidateError):
    """Invalid header"""


class MissingHeaderError(HeaderValidationError):
    """Missing header error"""


class MissingHeader(MissingHeaderError):
    def __str__(self) -> str:
        return f"Missing header (without default value): {self.name}"


class MissingRequiredHeader(MissingHeaderError):
    def __str__(self) -> str:
        return f"Missing required header: {self.name}"