"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from dub import utils
from dub.types import BaseModel
from enum import Enum
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class Code(str, Enum):
    r"""A short code indicating the error code returned."""

    BAD_REQUEST = "bad_request"


class ErrorTypedDict(TypedDict):
    code: Code
    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 Error(BaseModel):
    code: Code
    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"""


class BadRequestData(BaseModel):
    error: Error


class BadRequest(Exception):
    r"""The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing)."""

    data: BadRequestData

    def __init__(self, data: BadRequestData):
        self.data = data

    def __str__(self) -> str:
        return utils.marshal_json(self.data, BadRequestData)
