# ★ Constructor

## `RangeError()`

Creates the [`RangeError`](https://error.angular-package.dev/rangeerror) instance that represents range error with the [message](https://error.angular-package.dev/commonerror/accessors/get-message) built of the given described [`problem`](#problem-string) and its [solution](#fix-string), optional [`min`](#min-min)/[`max`](#max-max) range, and an explicit [identification](#id-id) on the given or stored error message [template](#template-string-rangerror.template).

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

```typescript
constructor(
  problem: string,
  fix: string,
  id?: Id,
  min?: Min,
  max?: Max,
  template = RangeError.template
) {
  super(problem, fix, id, template, { min, max });
  this.#max = max;
  this.#min = min;
}
```

{% 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 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#rangeerror-less-than-id-min-max-greater-than)

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

#### `min?:`[<mark style="color:green;">`Min`</mark>](https://error.angular-package.dev/generic-type-variables#rangeerror-less-than-id-min-max-greater-than-1)

The optional minimum range of generic type variable [`Min`](https://error.angular-package.dev/generic-type-variables#rangeerror-less-than-id-min-max-greater-than-1) that causes an error to be thrown(or not thrown).

#### `max?:`[<mark style="color:green;">`Max`</mark>](https://error.angular-package.dev/generic-type-variables#rangeerror-less-than-id-min-max-greater-than-2)

The optional maximum range of generic type variable [`Max`](https://error.angular-package.dev/generic-type-variables#rangeerror-less-than-id-min-max-greater-than-2) that causes an error to be thrown(or not thrown).

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

Optional template of the error message of [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type 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), [`{max}`](https://error.angular-package.dev/commonerror/properties/static-template#max), [`{min}`](https://error.angular-package.dev/commonerror/properties/static-template#min) tags. By default, the value is equal to the static property [`RangeError.template`](https://error.angular-package.dev/rangeerror/properties/static-template).

## Example usage

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

/*
  Returns
  RangeError: Problem(AE:427): The `age` parameter is too big, got 455 => Fix: Set the `age` parameter of the `setAge()` method between 9 and 27
*/
new RangeError(
  'The `age` parameter is too big, got 455', // Problem
  'Set the `age` parameter of the `setAge()` method', // Fix
  '(AE:427)', // Identification
  9,  // Minimum
  27 // Maximum range
);
```
