# ActioError (/docs/api/classes/ActioError)



Defined in: [packages/core/src/diagnostics.ts:34](https://github.com/austenstone/actio/blob/2b01e694a0f76521d8c073f3c6a2e48917d2c9d9/packages/core/src/diagnostics.ts#L34)

Thrown when a caller prefers exceptions over a result object.

## Extends [#extends]

* `Error`

## Constructors [#constructors]

### Constructor [#constructor]

```ts
new ActioError(message, diagnostics?): ActioError;
```

Defined in: [packages/core/src/diagnostics.ts:36](https://github.com/austenstone/actio/blob/2b01e694a0f76521d8c073f3c6a2e48917d2c9d9/packages/core/src/diagnostics.ts#L36)

#### Parameters [#parameters]

##### message [#message]

`string`

##### diagnostics? [#diagnostics]

[`Diagnostic`](../interfaces/Diagnostic.mdx)\[] = `[]`

#### Returns [#returns]

`ActioError`

#### Overrides [#overrides]

```ts
Error.constructor
```

## Properties [#properties]

### cause? [#cause]

```ts
optional cause?: unknown;
```

Defined in: docs/node\_modules/typescript/lib/lib.es2022.error.d.ts:24

#### Inherited from [#inherited-from]

```ts
Error.cause
```

***

### diagnostics [#diagnostics-1]

```ts
readonly diagnostics: Diagnostic[];
```

Defined in: [packages/core/src/diagnostics.ts:35](https://github.com/austenstone/actio/blob/2b01e694a0f76521d8c073f3c6a2e48917d2c9d9/packages/core/src/diagnostics.ts#L35)

***

### message [#message-1]

```ts
message: string;
```

Defined in: docs/node\_modules/typescript/lib/lib.es5.d.ts:1075

#### Inherited from [#inherited-from-1]

```ts
Error.message
```

***

### name [#name]

```ts
name: string;
```

Defined in: docs/node\_modules/typescript/lib/lib.es5.d.ts:1074

#### Inherited from [#inherited-from-2]

```ts
Error.name
```

***

### stack? [#stack]

```ts
optional stack?: string;
```

Defined in: docs/node\_modules/typescript/lib/lib.es5.d.ts:1076

#### Inherited from [#inherited-from-3]

```ts
Error.stack
```

***

### stackTraceLimit [#stacktracelimit]

```ts
static stackTraceLimit: number;
```

Defined in: node\_modules/@types/node/globals.d.ts:67

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 [#inherited-from-4]

```ts
Error.stackTraceLimit
```

## Methods [#methods]

### captureStackTrace() [#capturestacktrace]

```ts
static captureStackTrace(targetObject, constructorOpt?): void;
```

Defined in: node\_modules/@types/node/globals.d.ts:51

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
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
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 [#parameters-1]

##### targetObject [#targetobject]

`object`

##### constructorOpt? [#constructoropt]

`Function`

#### Returns [#returns-1]

`void`

#### Inherited from [#inherited-from-5]

```ts
Error.captureStackTrace
```

***

### prepareStackTrace() [#preparestacktrace]

```ts
static prepareStackTrace(err, stackTraces): any;
```

Defined in: node\_modules/@types/node/globals.d.ts:55

#### Parameters [#parameters-2]

##### err [#err]

`Error`

##### stackTraces [#stacktraces]

`CallSite`\[]

#### Returns [#returns-2]

`any`

#### See [#see]

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

#### Inherited from [#inherited-from-6]

```ts
Error.prepareStackTrace
```


## Sitemap

Browse the full documentation: [Markdown sitemap](https://austenstone.github.io/actio/sitemap.md) · [XML sitemap](https://austenstone.github.io/actio/sitemap.xml)