> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tappify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# TapError

> The error the SDK and the host raise when a call cannot be served at all.

The error the SDK and the host raise when a call cannot be served at all.

## Remarks

The SDK throws it for a mount outside the host (`TAP_OUTSIDE_HOST`), a
collection or procedure the manifest does not declare
(`TAP_UNKNOWN_COLLECTION`, `TAP_UNKNOWN_PROCEDURE`), a missing portal or query
client, a token the server rejected, and a misused testing helper. The host
turns a refused read or write into `TAP_SCOPE_MISSING`. Branch on `code`, which
is stable; the message is prose and changes. An error your own server raised is
a `TapServerError` instead.

## Example

```tsx theme={null}
import { TapError, TapErrorState, useTapQuery } from '@tappify/extension-sdk';

function Revenue() {
  const revenue = useTapQuery({
    kind: 'revenue',
    range: { from: '2026-09-01', to: '2026-09-08' },
  });
  if (TapError.is(revenue.error) && revenue.error.code === 'TAP_SCOPE_MISSING') {
    return <TapErrorState title="Revenue is not shared with this extension" />;
  }
  return <span>{revenue.data?.mrr ?? 0}</span>;
}
```

## Extends

* `Error`

## Constructors

### Constructor

```ts theme={null}
new TapError(code, message): TapError;
```

#### Parameters

##### code

[`TapErrorCode`](/extensions/reference/frontend-api/TypeAlias.TapErrorCode)

##### message

`string`

#### Returns

`TapError`

#### Overrides

```ts theme={null}
Error.constructor
```

## Properties

### code

```ts theme={null}
readonly code: TapErrorCode;
```

***

### message

```ts theme={null}
message: string;
```

#### Inherited from

```ts theme={null}
Error.message
```

***

### name

```ts theme={null}
name: string;
```

#### Inherited from

```ts theme={null}
Error.name
```

***

### stack?

```ts theme={null}
optional stack?: string;
```

#### Inherited from

```ts theme={null}
Error.stack
```

***

### stackTraceLimit

```ts theme={null}
static stackTraceLimit: number;
```

The `Error.stackTraceLimit` property specifies the number of stack frames
collected by a stack trace (whether generated by `new Error().stack` or
`Error.captureStackTrace(obj)`).

The default value is `10` but may be set to any valid JavaScript number. Changes
will affect any stack trace captured *after* the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.

#### Inherited from

```ts theme={null}
Error.stackTraceLimit
```

## Methods

### captureStackTrace()

```ts theme={null}
static captureStackTrace(targetObject, constructorOpt?): void;
```

Creates a `.stack` property on `targetObject`, which when accessed returns
a string representing the location in the code at which
`Error.captureStackTrace()` was called.

```js theme={null}
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`
```

The first line of the trace will be prefixed with
`${myObject.name}: ${myObject.message}`.

The optional `constructorOpt` argument accepts a function. If given, all frames
above `constructorOpt`, including `constructorOpt`, will be omitted from the
generated stack trace.

The `constructorOpt` argument is useful for hiding implementation
details of error generation from the user. For instance:

```js theme={null}
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
```

#### Parameters

##### targetObject

`object`

##### constructorOpt?

`Function`

#### Returns

`void`

#### Inherited from

```ts theme={null}
Error.captureStackTrace
```

***

### is()

```ts theme={null}
static is(value): value is TapError;
```

Narrows an unknown value to a `TapError`, by name and by a code it
recognises, so it holds across module instances.

#### Parameters

##### value

`unknown`

#### Returns

`value is TapError`

***

### prepareStackTrace()

```ts theme={null}
static prepareStackTrace(err, stackTraces): any;
```

#### Parameters

##### err

`Error`

##### stackTraces

`CallSite`\[]

#### Returns

`any`

#### See

[https://v8.dev/docs/stack-trace-api#customizing-stack-traces](https://v8.dev/docs/stack-trace-api#customizing-stack-traces)

#### Inherited from

```ts theme={null}
Error.prepareStackTrace
```
