# 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>](https://docs.angular-package.dev/error/commonerror)`<`[<mark style="color:green;">`Id`</mark>](https://docs.angular-package.dev/error/generic-type-variables#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`](https://docs.angular-package.dev/error/commonerror) object that takes generic type variable [`Id`](https://docs.angular-package.dev/error/generic-type-variables#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)');
```
