> For the complete documentation index, see [llms.txt](https://error.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://error.angular-package.dev/draft-5/commonerror/methods/static-iserror.md).

# static isError()

## `CommonError.isError()`

Checks whether the [`value`](#value-any) of [`any`](https://www.typescriptlang.org/docs/handbook/basic-types.html#any) type is a `this` instance of any or the given [identification](#id-id).

{% code title="common-error.class.ts" %}

```typescript
protected static isError<Id extends string>(
  value: any,
  id?: Id
): value is CommonError<Id> {
  return typeof value === 'object' && value instanceof this
    ? typeof id === 'string'
      ? value.id === id
      : true
    : false;
}
```

{% endcode %}

### Generic type variables

#### <mark style="color:green;">`Id`</mark>`extends`[<mark style="color:green;">`string`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#string)

A generic type variable constrained by the [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string) indicates the&#x20;

### Parameters

#### `value:`[<mark style="color:green;">`any`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#any)

The value of [`any`](https://www.typescriptlang.org/docs/handbook/basic-types.html#any) type to check against the `this` instance.

#### `id?:`[<mark style="color:green;">`Id`</mark>](#idextendsstring)

Optional identification of generic type variable [`Id`](#idextendsstring) to check whether the given [`value`](#value-any) contains.

### Return type

#### `value is`[<mark style="color:green;">`CommonError`</mark>](/draft-5/commonerror/overview.md)`<`[<mark style="color:green;">`Id`</mark>](/draft-5/commonerror/generic-type-variables.md#commonerror-less-than-id-greater-than)`>`

The **return type** is a [`boolean`](https://www.typescriptlang.org/docs/handbook/basic-types.html#boolean) indicating the [`value`](#value-any) is the [`CommonError`](/draft-5/commonerror/overview.md) object that takes generic type variable [`Id`](/draft-5/commonerror/generic-type-variables.md#commonerror-less-than-id-greater-than).

### Returns

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) type indicating whether the given [`value`](#value-any) is a `this` instance of any or the given [`id`](#id-id).

## Example usage

```typescript
// Example usage.
import { CommonError } from '@angular-package/error';

class TestError<Id extends string> extends CommonError<Id> {
  public static isError<Id extends string>(
    value: any,
    id?: Id
  ): value is TestError<Id> {
    return super.isError(value, id);
  }
}

const testError = new TestError(
  'Problem accessor.',
  'Fix accessor.',
  '(AE:427)',
  '{problem} {fix} {id}'
);

// Returns "true".
TestError.isError(testError, '(AE:427)');
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://error.angular-package.dev/draft-5/commonerror/methods/static-iserror.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
