-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinternalservererror.py
More file actions
75 lines (55 loc) · 2.24 KB
/
internalservererror.py
File metadata and controls
75 lines (55 loc) · 2.24 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from dataclasses import dataclass, field
from dub.models.errors import DubError
from dub.types import BaseModel, UNSET_SENTINEL
from enum import Enum
import httpx
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
class InternalServerErrorCode(str, Enum):
r"""A short code indicating the error code returned."""
INTERNAL_SERVER_ERROR = "internal_server_error"
class InternalServerErrorErrorTypedDict(TypedDict):
code: InternalServerErrorCode
r"""A short code indicating the error code returned."""
message: str
r"""A human readable explanation of what went wrong."""
doc_url: NotRequired[str]
r"""A link to our documentation with more details about this error code"""
class InternalServerErrorError(BaseModel):
code: InternalServerErrorCode
r"""A short code indicating the error code returned."""
message: str
r"""A human readable explanation of what went wrong."""
doc_url: Optional[str] = None
r"""A link to our documentation with more details about this error code"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["doc_url"])
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k)
if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val
return m
class InternalServerErrorData(BaseModel):
error: InternalServerErrorError
@dataclass(unsafe_hash=True)
class InternalServerError(DubError):
r"""The server has encountered a situation it does not know how to handle."""
data: InternalServerErrorData = field(hash=False)
def __init__(
self,
data: InternalServerErrorData,
raw_response: httpx.Response,
body: Optional[str] = None,
):
fallback = body or raw_response.text
message = str(data.error.message) or fallback
super().__init__(message, raw_response, body)
object.__setattr__(self, "data", data)