# getDeepError

> This document is the Markdown version of [formisch.dev/methods/api/getDeepError/](https://formisch.dev/methods/api/getDeepError/). For the complete documentation index, see [llms.txt](https://formisch.dev/llms.txt).

Retrieves the first error message of a specific field or the entire form by walking through the field store and all its descendants and stopping at the first field with errors. This is useful for displaying a single error message for a field whose value is a nested structure, such as a rich text editor or tags input.

```ts
const error = getDeepError<TSchema>(form);
const error = getDeepError<TSchema, TFieldPath>(form, config);
```

## Generics

- `TSchema` `extends FormSchema`
- `TFieldPath` `extends RequiredPath | undefined = undefined`

## Parameters

- `form` `BaseFormStore<TSchema>`
- `config` `GetFormDeepErrorConfig | GetFieldDeepErrorConfig<TSchema, TFieldPath> | undefined`

### Explanation

The `form` parameter is the form store to retrieve the error from. The optional `config` parameter scopes the search to a specific field's subtree via a `path` (when omitted, the entire form is walked). The function walks through the field store and all its descendants in depth-first order and stops at the first field with errors, so errors of a field surface before errors of its descendants.

## Returns

- `result` `string | null`

## Related

### Primitives

[`useForm`](/react/api/useForm.md)

### Methods

[`getErrors`](/methods/api/getErrors.md), [`getDeepErrors`](/methods/api/getDeepErrors.md), [`getDeepErrorEntry`](/methods/api/getDeepErrorEntry.md), [`validate`](/methods/api/validate.md)
