# ComponentEmbedError

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

<https://docs.seedcord.org/packages/discord-component-embed/0.2.2/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.2.2/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,
    options?: ErrorOptions
)
```

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
```
