[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/script-host](https://jsprismarine.dev/api/@jsprismarine/script-host/index.md) / [errors](https://jsprismarine.dev/api/@jsprismarine/script-host/errors/index.md) / ScriptApiError

# Class: ScriptApiError

Defined in: [script-host/src/errors.ts:58](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/errors.ts#L58)

Thrown by a member's implementation to throw one of the API's own error classes in the script,
such as `LocationInUnloadedChunkError`, with the fields its properties read.

## Extends

- `ApiError`

## Constructors

### Constructor

> **new ScriptApiError**(`errorModule`, `errorClass`, `message`, `fields?`): `ScriptApiError`

Defined in: [script-host/src/errors.ts:72](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/errors.ts#L72)

#### Parameters

##### errorModule

`string`

The module that declares the error class, such as `@minecraft/server`.

##### errorClass

`string`

The error class, such as `LocationInUnloadedChunkError`.

##### message

`string`

The message the script sees.

##### fields?

`Readonly`\<`Record`\<`string`, [`ScriptApiErrorField`](https://jsprismarine.dev/api/@jsprismarine/script-host/errors/index.md#scriptapierrorfield)\>\> = `{}`

Values for the error's properties.

#### Returns

`ScriptApiError`

#### Overrides

`ScriptHostErrors.ApiError.constructor`

## Properties

### code

> `readonly` **code**: `"SCRIPT_HOST_API_ERROR"` = `'SCRIPT_HOST_API_ERROR'`

Defined in: [errors/src/script-host.ts:552](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/errors/src/script-host.ts#L552)

#### Inherited from

`ScriptHostErrors.ApiError.code`

***

### docs

> `readonly` **docs**: `"https://jsprismarine.dev/errors/script-host#script-host-api-error"` = `'https://jsprismarine.dev/errors/script-host#script-host-api-error'`

Defined in: [errors/src/script-host.ts:553](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/errors/src/script-host.ts#L553)

#### Inherited from

`ScriptHostErrors.ApiError.docs`

***

### errorClass

> `readonly` **errorClass**: `string`

Defined in: [script-host/src/errors.ts:63](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/errors.ts#L63)

The error class's name.

***

### errorModule

> `readonly` **errorModule**: `string`

Defined in: [script-host/src/errors.ts:61](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/errors.ts#L61)

The error class's module.

***

### fields

> `readonly` **fields**: `Readonly`\<`Record`\<`string`, [`ScriptApiErrorField`](https://jsprismarine.dev/api/@jsprismarine/script-host/errors/index.md#scriptapierrorfield)\>\>

Defined in: [script-host/src/errors.ts:64](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/errors.ts#L64)

***

### name

> `readonly` **name**: `"ScriptApiError"` = `'ScriptApiError'`

Defined in: [script-host/src/errors.ts:59](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/errors.ts#L59)

#### Overrides

`ScriptHostErrors.ApiError.name`

## Accessors

### \[cataloged\]

#### Get Signature

> **get** **\[cataloged\]**(): `true`

Defined in: [errors/src/JSPrismarineError.ts:40](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/errors/src/JSPrismarineError.ts#L40)

##### Returns

`true`

#### Inherited from

`ScriptHostErrors.ApiError.[cataloged]`

***

### params

#### Get Signature

> **get** **params**(): `object` & `Readonly`\<`Record`\<`string`, `unknown`\>\>

Defined in: [errors/src/script-host.ts:562](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/errors/src/script-host.ts#L562)

The placeholder values the message was built from.

##### Returns

`object` & `Readonly`\<`Record`\<`string`, `unknown`\>\>

#### Inherited from

`ScriptHostErrors.ApiError.params`

***

### code

#### Get Signature

> **get** `static` **code**(): `"SCRIPT_HOST_API_ERROR"`

Defined in: [errors/src/script-host.ts:539](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/errors/src/script-host.ts#L539)

##### Returns

`"SCRIPT_HOST_API_ERROR"`

#### Inherited from

`ScriptHostErrors.ApiError.code`

***

### docs

#### Get Signature

> **get** `static` **docs**(): `"https://jsprismarine.dev/errors/script-host#script-host-api-error"`

Defined in: [errors/src/script-host.ts:548](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/errors/src/script-host.ts#L548)

##### Returns

`"https://jsprismarine.dev/errors/script-host#script-host-api-error"`

#### Inherited from

`ScriptHostErrors.ApiError.docs`

***

### domain

#### Get Signature

> **get** `static` **domain**(): `"script-host"`

Defined in: [errors/src/script-host.ts:542](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/errors/src/script-host.ts#L542)

##### Returns

`"script-host"`

#### Inherited from

`ScriptHostErrors.ApiError.domain`

***

### template

#### Get Signature

> **get** `static` **template**(): `"{message}"`

Defined in: [errors/src/script-host.ts:545](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/errors/src/script-host.ts#L545)

##### Returns

`"{message}"`

#### Inherited from

`ScriptHostErrors.ApiError.template`
