Repository navigation
Expand file tree
/
Copy pathinternalservererror.py
More file actions
55 lines (47 loc) · 1.93 KB
/
Copy pathinternalservererror.py
File metadata and controls
55 lines (47 loc) · 1.93 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
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from dataclasses import dataclass, field
import httpx
from moderation_api.errors import ModerationAPIError
from moderation_api.models import (
errorissue as models_errorissue,
internalservererror as models_internalservererror,
)
from moderation_api.types import BaseModel
from moderation_api.utils import validate_const
import pydantic
from pydantic.functional_validators import AfterValidator
from typing import List, Literal, Optional
from typing_extensions import Annotated
class InternalServerErrorData(BaseModel):
code: models_internalservererror.InternalServerErrorCode
r"""Exactly what went wrong. Stable; safe to branch on. New codes may be added.
- `internal_error`: Something went wrong on our side. Retry with backoff.
"""
message: str
r"""Human-readable explanation."""
request_id: str
r"""Identifies this request. Include it when you contact support."""
doc_url: str
r"""Documentation for this `code`."""
type: Annotated[
Annotated[Literal["api_error"], AfterValidator(validate_const("api_error"))],
pydantic.Field(alias="type"),
] = "api_error"
r"""Broad error category. Stable; safe to switch on."""
issues: Optional[List[models_errorissue.ErrorIssue]] = None
r"""Validation problems, when the request body is invalid."""
@dataclass(unsafe_hash=True)
class InternalServerError(ModerationAPIError):
r"""Something went wrong on our side. Retry with backoff."""
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.message) or fallback
super().__init__(message, raw_response, body)
object.__setattr__(self, "data", data)