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

from __future__ import annotations
from .entity_error_object import EntityErrorObject
from gusto_app_integration import utils
from gusto_app_integration.types import BaseModel
from typing import List, Optional


class UnprocessableEntityErrorObjectData(BaseModel):
    errors: Optional[List[EntityErrorObject]] = None


class UnprocessableEntityErrorObject(Exception):
    r"""Unprocessable Entity

    This may happen when the body of your request contains errors such as `invalid_attribute_value`, or the request fails due to an `invalid_operation`. See the [Errors Categories](https://docs.gusto.com/embedded-payroll/docs/error-categories) guide for more details.

    """

    data: UnprocessableEntityErrorObjectData

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

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