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

from __future__ import annotations
from dataclasses import dataclass, field
from fermisdk.errors import FermisdkError
from fermisdk.types import BaseModel
import httpx
from typing import Optional


class ErrorData(BaseModel):
    error: Optional[str] = None
    r"""Error message"""
    detail: Optional[str] = None
    r"""Detailed error information"""


@dataclass(unsafe_hash=True)
class Error(FermisdkError):
    data: ErrorData = field(hash=False)

    def __init__(
        self, data: ErrorData, raw_response: httpx.Response, body: Optional[str] = None
    ):
        message = body or raw_response.text
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)
