# Notice

`class` in `core` · v0.2.1

<https://docs.seedcord.org/packages/core/0.2.1/classes/notice>

Base class for a user-facing refusal or a reported fault.

Throw a `Notice` to stop a handler and reply to the user. The framework catches it at the controller boundary and renders [`render`](/packages/core/0.2.1/classes/notice#render), which always decides what the user sees. With `report` false that render is all that happens. With `report` true the framework also logs the fault and publishes it to the `handledException` bus. A raw, non-Notice throw shows the generic message.

```ts
abstract class Notice extends Error
```

## Examples

```ts
import { Notice, BuilderComponent, type RenderContext, type ReplyResponse } from '@seedcord/gateway';
import { TextDisplayBuilder } from '@discordjs/builders';

// reading `.component` applies the configured bot color to the container accent
class TooPoorCard extends BuilderComponent<'container'> {
    constructor(balance: number) {
        super('container');
        this.instance.addTextDisplayComponents(
            new TextDisplayBuilder().setContent(`### Insufficient balance\nYou need more than ${balance} coins.`)
        );
    }
}

class TooPoor extends Notice {
    constructor(private readonly balance: number) {
        super(`balance ${balance} is below the cost`);
    }

    render(_ctx: RenderContext): ReplyResponse {
        return { components: [new TooPoorCard(this.balance).component] };
    }
}

// in a handler, throwing stops the handler and replies with render(ctx)
if (wallet.balance < cost) throw new TooPoor(wallet.balance);
```

## Constructors

### constructor

```ts
protected Notice(message: string, options?: ErrorOptions)
```

Constructs a new instance of the `Notice` class

## Properties

### ephemeral

```ts
public ephemeral: boolean
```

Whether the reply is ephemeral, seen only by the invoking user. Set it false for a refusal the whole channel should see.

### report

```ts
public report: boolean
```

Whether this denial is a reported fault. True also logs it and publishes it to the `handledException` bus. The user always sees [`render`](/packages/core/0.2.1/classes/notice#render) either way.

### summary

```ts
public summary: string
```

A short one-line reason. When every arm of an `or` gate refuses and each refusal sets this, `or` lists them as the reply.

## Methods

### render

```ts
public abstract render(ctx: RenderContext): ReplyResponse
```

Builds what the user sees. Called fresh each time the denial is shown, so the builders are new and the bot color resolves at render time.
