# This file was auto-generated by Fern from our API Definition.

from ..core.unchecked_base_model import UncheckedBaseModel
from .error_category import ErrorCategory
import pydantic
from .error_code import ErrorCode
import typing
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class Error(UncheckedBaseModel):
    """
    Represents an error encountered during a request to the Connect API.

    See [Handling errors](https://developer.squareup.com/docs/build-basics/handling-errors) for more information.
    """

    category: ErrorCategory = pydantic.Field()
    """
    The high-level category for the error.
    See [ErrorCategory](#type-errorcategory) for possible values
    """

    code: ErrorCode = pydantic.Field()
    """
    The specific code of the error.
    See [ErrorCode](#type-errorcode) for possible values
    """

    detail: typing.Optional[str] = pydantic.Field(default=None)
    """
    A human-readable description of the error for debugging purposes.
    """

    field: typing.Optional[str] = pydantic.Field(default=None)
    """
    The name of the field provided in the original request (if any) that
    the error pertains to.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
