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 (38 lines) | stat: -rw-r--r-- 907 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
from dataclasses import dataclass

from openapi_core.deserializing.exceptions import DeserializeError


@dataclass
class BaseStyleDeserializeError(DeserializeError):
    """Base style deserialize operation error"""

    location: str


@dataclass
class ParameterDeserializeError(BaseStyleDeserializeError):
    """Parameter deserialize operation error"""

    style: str
    value: str

    def __str__(self) -> str:
        return (
            "Failed to deserialize value of "
            f"{self.location} parameter with style {self.style}: {self.value}"
        )


@dataclass(init=False)
class EmptyQueryParameterValue(BaseStyleDeserializeError):
    name: str

    def __init__(self, name: str):
        super().__init__(location="query")
        self.name = name

    def __str__(self) -> str:
        return (
            f"Value of {self.name} {self.location} parameter cannot be empty"
        )