# ComponentEmbedError

`class` in `discord-component-embed` · v0.4.1

<https://docs.seedcord.org/packages/discord-component-embed/0.4.1/classes/component-embed-error>

Thrown when a component tree breaks a rule of Discord's component embed format, or when your own code throws while the package reads the tree. Read [`code`](/packages/discord-component-embed/0.4.1/classes/component-embed-error#code) to tell which. Discord drops an invalid payload and falls back to the Open Graph card. The card you see is your only signal.

```ts
class ComponentEmbedError extends Error
```

## Examples

```ts
try {
    toComponentEmbed(<GuidePreview page={page} />);
} catch (error) {
    if (error instanceof ComponentEmbedError && error.code === 'ReadFailed') console.error(error.cause);
    throw error;
}
```

## Constructors

### constructor

```ts
ComponentEmbedError(
    code: ComponentEmbedErrorCode,
    message: string,
    { path, ...options }?,
    input?: ErrorOptions & { path?: readonly string[] }
)
```

Constructs a new instance of the `ComponentEmbedError` class

## Properties

### code

```ts
public readonly code: ComponentEmbedErrorCode
```

Which rule the tree broke.

### name

```ts
public readonly name
```

### path

```ts
public readonly path: readonly string[]
```

The steps from the root to the component that broke a rule, like `['Container', 'PostCard', 'Section 2']`. Your own components appear by name. A number marks a component written next to others with the same name. The path is empty when the problem is the whole embed, like its size. For a tree from [`fromPayload`](/packages/discord-component-embed/0.4.1/functions/from-payload), the steps are JSON keys and array indexes counted from 0, like `['component', 'components', '1']`.
