# ★ Constructor

## `Error()`

Creates the [`Error`](https://error.angular-package.dev/error) instance with the [message](https://error.angular-package.dev/commonerror/accessors/get-message) built from the given described [`problem`](#problem-string) and its [solution](#fix-string), optional explicit [identification](#id-id) on the given or stored [`template`](#template-string-error.template).

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

```typescript
constructor(
  problem: string,
  fix: string,
  id?: Id,
  template = Error.template
) {
  super(problem, fix, id, template);
}
```

{% endcode %}

### Parameters

#### `problem:`[<mark style="color:green;">`string`</mark>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)

Description of the [problem](https://error.angular-package.dev/getting-started/basic-concepts#problem) of a [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type.

#### `fix:`[<mark style="color:green;">`string`</mark>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)

A solution to the given [`problem`](#problem-string) of a [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type.

#### `id?:`[<mark style="color:green;">`Id`</mark>](https://error.angular-package.dev/generic-type-variables#wrap-opening)

Optional unique [identification](https://error.angular-package.dev/getting-started/basic-concepts#identification) to the given [`problem`](#problem-string) of generic type variable [`Id`](https://error.angular-package.dev/commonerror/generic-type-variables#commonerror-less-than-id-greater-than).

#### `template:`[<mark style="color:green;">`string`</mark>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)`=`<mark style="color:green;">`Error`</mark>`.template`

A template of error message with the replaceable [`{problem}`](https://error.angular-package.dev/commonerror/properties/static-template#problem), [`{fix}`](https://error.angular-package.dev/commonerror/properties/static-template#fix) and optional [`{id}`](https://error.angular-package.dev/commonerror/properties/static-template#id) tags. By default, the value is equal to the static property [`template`](https://error.angular-package.dev/commonerror/properties/static-template).

## Example usage

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

// Returns "Error: ProblemTE:201: Wrong type => Fix: Change the type".
new Error('Wrong type', 'Change the type', 'TE:201');
```
