-
-
Notifications
You must be signed in to change notification settings - Fork 133
/
Copy pathexceptions.py
46 lines (32 loc) · 1.06 KB
/
exceptions.py
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
import warnings
from dataclasses import dataclass
from typing import Iterable
from openapi_core.exceptions import OpenAPIError
from openapi_core.validation.request.datatypes import Parameters
from openapi_core.validation.request.protocols import Request
@dataclass
class ParametersError(Exception):
parameters: Parameters
errors: Iterable[Exception]
@property
def context(self) -> Iterable[Exception]:
warnings.warn(
"context property of ParametersError is deprecated. "
"Use erros instead.",
DeprecationWarning,
)
return self.errors
class OpenAPIRequestBodyError(OpenAPIError):
pass
class MissingRequestBodyError(OpenAPIRequestBodyError):
"""Missing request body error"""
@dataclass
class MissingRequestBody(MissingRequestBodyError):
request: Request
def __str__(self) -> str:
return "Missing request body"
@dataclass
class MissingRequiredRequestBody(MissingRequestBodyError):
request: Request
def __str__(self) -> str:
return "Missing required request body"