# Source: https://docs.apify.com/api/client/python/reference/class/ApifyApiError.md

# Source: https://docs.apify.com/api/client/js/reference/class/ApifyApiError.md

# ApifyApiError<!-- -->

An `ApifyApiError` is thrown for successful HTTP requests that reach the API, but the API responds with an error response. Typically, those are rate limit errors and internal errors, which are automatically retried, or validation errors, which are thrown immediately, because a correction by the user is needed.

### Hierarchy

* Error
  * *ApifyApiError*

## Index[**](#Index)

### Properties

* [**attempt](#attempt)
* [**cause](#cause)
* [**clientMethod](#clientMethod)
* [**data](#data)
* [**httpMethod](#httpMethod)
* [**message](#message)
* [**name](#name)
* [**originalStack](#originalStack)
* [**path](#path)
* [**stack](#stack)
* [**statusCode](#statusCode)
* [**type](#type)
* [**stackTraceLimit](#stackTraceLimit)

### Methods

* [**captureStackTrace](#captureStackTrace)
* [**prepareStackTrace](#prepareStackTrace)

## Properties<!-- -->[**](#Properties)

### [**](#attempt)[**](https://github.com/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/src/apify_api_error.ts#L46)attempt

**attempt: number

Number of the API call attempt.

### [**](#cause)[**](https://undefined/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/website/node_modules/typescript/src/lib.es2022.error.d.ts#L24)externaloptionalinheritedcause

**cause?

<!-- -->

: unknown

Inherited from Error.cause

### [**](#clientMethod)[**](https://github.com/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/src/apify_api_error.ts#L31)clientMethod

**clientMethod: string

The invoked resource client and the method. Known issue: Sometimes it displays as `unknown` because it can't be parsed from a stack trace.

### [**](#data)[**](https://github.com/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/src/apify_api_error.ts#L67)optionaldata

**data?

<!-- -->

: Record\<string, unknown>

Additional data provided by the API about the error

### [**](#httpMethod)[**](https://github.com/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/src/apify_api_error.ts#L51)optionalhttpMethod

**httpMethod?

<!-- -->

: string

HTTP method of the API call.

### [**](#message)[**](https://undefined/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/website/node_modules/typescript/src/lib.es5.d.ts#L1077)externalinheritedmessage

**message: string

Inherited from Error.message

### [**](#name)[**](https://github.com/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/src/apify_api_error.ts#L25)name

**name: string

Overrides Error.name

### [**](#originalStack)[**](https://github.com/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/src/apify_api_error.ts#L62)originalStack

**originalStack: string

Original stack trace of the exception. It is replaced by a more informative stack with API call information.

### [**](#path)[**](https://github.com/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/src/apify_api_error.ts#L56)optionalpath

**path?

<!-- -->

: string

Full path of the API endpoint (URL excluding origin).

### [**](#stack)[**](https://undefined/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/website/node_modules/typescript/src/lib.es5.d.ts#L1078)externaloptionalinheritedstack

**stack?

<!-- -->

: string

Inherited from Error.stack

### [**](#statusCode)[**](https://github.com/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/src/apify_api_error.ts#L36)statusCode

**statusCode: number

HTTP status code of the error.

### [**](#type)[**](https://github.com/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/src/apify_api_error.ts#L41)optionaltype

**type?

<!-- -->

: string

The type of the error, as returned by the API.

### [**](#stackTraceLimit)[**](https://undefined/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/node_modules/@types/node/globals.d.ts#L68)staticexternalinheritedstackTraceLimit

**stackTraceLimit: number

Inherited from Error.stackTraceLimit

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.

## Methods<!-- -->[**](#Methods)

### [**](#captureStackTrace)[**](https://undefined/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/node_modules/@types/node/globals.d.ts#L52)staticexternalinheritedcaptureStackTrace

* ****captureStackTrace**(targetObject, constructorOpt): void

- Inherited from Error.captureStackTrace

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

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

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

  * ##### externaltargetObject: object
  * ##### externaloptionalconstructorOpt: Function

  #### Returns void

### [**](#prepareStackTrace)[**](https://undefined/apify/apify-client-js/blob/a8a29bacd7df19373e3300fc059110221bc37e09/node_modules/@types/node/globals.d.ts#L56)staticexternalinheritedprepareStackTrace

* ****prepareStackTrace**(err, stackTraces): any

- Inherited from Error.prepareStackTrace

  * **@see**

    <https://v8.dev/docs/stack-trace-api#customizing-stack-traces>

  ***

  #### Parameters

  * ##### externalerr: Error
  * ##### externalstackTraces: CallSite\[]

  #### Returns any