import { ZodError } from 'zod' import { IORenderInstruction } from '~/components/RenderIOCall' import { pluralize } from '~/utils/text' export class IOComponentError extends Error { constructor(message?: string) { super(message ?? 'This field is required.') } } function pathToString(path: (string | number)[]) { if (path.length === 0) return '' return ( path[0] + path .slice(1) .map(p => `[${p}]`) .join('') ) } export default function ComponentError({ component, error, }: { component?: IORenderInstruction error: Pick }) { return (
{component && (

Label: {component.label ?? No label}

)}

This {component ? 'field' : 'action'} contains the following{' '} {pluralize(error.issues.length, 'error')}:

Please correct your action code and try again.

) }