# LayoutDiagnostic and layoutDiagnostic

```ts
import { LayoutDiagnostic, layoutDiagnostic } from "@pibbl/core";
```

`LayoutDiagnostic` is the runtime error class for contextual layout failures.
`layoutDiagnostic(input)` constructs the same error. Both expose component,
property, supplied value, algorithm, and optional constraints, preserving a
useful diagnostic when public geometry or style validation fails.

```ts
throw layoutDiagnostic({
  property: "width",
  value: -1,
  reason: "must be nonnegative",
});
```

Its [`LayoutDiagnosticInput`](/reference/types/layout/#layoutdiagnosticinput) and [`LayoutDiagnosticContext`](/reference/types/layout/#layoutdiagnosticcontext) types belong to the Layout type reference.

## API details from source

<span id="api-LayoutDiagnostic"></span>

### LayoutDiagnostic

A layout validation error carrying the affected property and component context.

```ts
class LayoutDiagnostic extends Error
```

Related API: [LayoutDiagnostic](/reference/functions/layout-diagnostic/).

#### See also

[layoutDiagnostic](/reference/functions/layout-diagnostic/)

[View source — packages/core/src/lib/style/diagnostics.ts:51](/source/packages/core/src/lib/style/diagnostics-ts/#L51)

#### Properties and methods

<span id="api-LayoutDiagnostic-component"></span>
<details>
<summary>component</summary>


```ts
readonly component: string
```

Component identity or diagnostic name associated with this value. See LayoutDiagnostic
.

[View source — packages/core/src/lib/style/diagnostics.ts:56](/source/packages/core/src/lib/style/diagnostics-ts/#L56)

</details>

<span id="api-LayoutDiagnostic-property"></span>
<details>
<summary>property</summary>


```ts
readonly property: string
```

Name of the affected input property. See LayoutDiagnostic.

[View source — packages/core/src/lib/style/diagnostics.ts:58](/source/packages/core/src/lib/style/diagnostics-ts/#L58)

</details>

<span id="api-LayoutDiagnostic-suppliedValue"></span>
<details>
<summary>suppliedValue</summary>


```ts
readonly suppliedValue: unknown
```

The original value that failed validation. See LayoutDiagnostic.

[View source — packages/core/src/lib/style/diagnostics.ts:60](/source/packages/core/src/lib/style/diagnostics-ts/#L60)

</details>

<span id="api-LayoutDiagnostic-algorithm"></span>
<details>
<summary>algorithm</summary>


```ts
readonly algorithm: string
```

Name of the layout algorithm producing this diagnostic or resolution. See
LayoutDiagnostic.

[View source — packages/core/src/lib/style/diagnostics.ts:65](/source/packages/core/src/lib/style/diagnostics-ts/#L65)

</details>

<span id="api-LayoutDiagnostic-constraints"></span>
<details>
<summary>constraints</summary>


```ts
readonly constraints: Readonly<Constraints> | undefined
```

Related API: [Constraints](/reference/types/layout/#constraints).

Sizing limits and available dimensions for this operation. See Constraints.

[View source — packages/core/src/lib/style/diagnostics.ts:67](/source/packages/core/src/lib/style/diagnostics-ts/#L67)

</details>

<span id="api-layoutDiagnostic"></span>

### layoutDiagnostic

Creates a structured layout error from a validation failure and its component context.

```ts
layoutDiagnostic: (input: LayoutDiagnosticInput) => LayoutDiagnostic
```

Related API: [layoutDiagnostic](/reference/functions/layout-diagnostic/), [LayoutDiagnosticInput](/reference/types/layout/#layoutdiagnosticinput), [LayoutDiagnostic](/reference/functions/layout-diagnostic/).

#### Parameters

- **`input`** — Diagnostic code, message, property, and layout context. See
[LayoutDiagnosticInput](/reference/types/layout/#layoutdiagnosticinput) .

#### Returns

A structured layout diagnostic. See [LayoutDiagnostic](/reference/functions/layout-diagnostic/).

#### See also

[LayoutDiagnosticInput](/reference/types/layout/#layoutdiagnosticinput)

[LayoutDiagnostic](/reference/functions/layout-diagnostic/)

[View source — packages/core/src/lib/style/diagnostics.ts:102](/source/packages/core/src/lib/style/diagnostics-ts/#L102)

## Implementation guidance for agents

Read the [Drawing, layout, and effects companion](/agents/topics/layout/) for ownership, adaptation, failure modes, and verification. [Agent start](/agents/) provides the version-selection workflow.

## Complete minimal examples

- [Box resolution](/minimal-examples/layout/box-helpers/): Resolve padding, percentages, and a constrained box with typed diagnostics. [Plain source](/minimal/layout/box-helpers.ts)
## Documentation version

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.
