# Constructor

## `CommonErrors()`

Creates an instance of the errors storage with [unique identification](https://error.angular-package.dev/draft-5/getting-started/basic-concepts#unique-identification) numbers.

{% hint style="info" %}
Identification numbers given in the rest parameter [`id`](#...id-id) are used by the instance [`isAllowedId()`](https://error.angular-package.dev/draft-5/commonerrors/methods/isallowedid) method to check the existence of the specific [`id`](#...id-id).
{% endhint %}

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

```typescript
constructor(...id: Id[]) {
  Array.isArray(id) && (this.#id = new Set(id));
}
```

{% endcode %}

### Parameters

#### `...id:`[<mark style="color:green;">`Id`</mark>](https://error.angular-package.dev/draft-5/generic-type-variables#commonerrors-less-than-id-greater-than)`[]`

A [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) of generic type variable [`Id`](https://error.angular-package.dev/draft-5/generic-type-variables#commonerrors-less-than-id-greater-than) indicates [unique identification](https://error.angular-package.dev/draft-5/getting-started/basic-concepts#unique-identification) numbers under which the errors are stored in the object.

## Example usage

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

class CustomErrors<Id extends string> extends CommonErrors<Id> {
  constructor(...id: Id[]) {
    super(...id);
  }
}

// Initialize `CustomErrors` without defined `id`.
// Returns CustomErrors {} of CustomErrors<string>
new CustomErrors();

// Initialize `CustomErrors` with defined `id`.
// Returns CustomErrors {} of CustomErrors<"ERR1" | "ERR2" | "ERR3">
new CustomErrors('ERR1', 'ERR2', 'ERR3');
```
