/** Describes a backend error payload returned from the API. */
export interface BackendErrorDetail
{
    code: number | string;
    message?: string;
    [key: string]: unknown;
}

/** Error wrapper that carries backend validation details. */
export default class BackendError extends Error
{
    public readonly details: BackendErrorDetail[];

    constructor(message: string, details: BackendErrorDetail[] = [])
    {
        super(message);
        this.name = 'BackendError';
        this.details = details;
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
