# get()

## `Errors.prototype.get()`

Returns the [`Error`](https://docs.angular-package.dev/error/error) instance of the given unique identification [`id`](#id-errorid) if set, otherwise [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined).

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

```typescript
public get<ErrorId extends Id>(id: ErrorId): Error<ErrorId> | undefined {
  return this.errors.get(id);
}
```

{% endcode %}

### Generic type variables

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

A generic type variable `ErrorId` constrained by the generic type variable [`Id`](https://docs.angular-package.dev/error/generic-type-variables#errors-less-than-id-greater-than) of the [`Errors`](https://docs.angular-package.dev/error/errors) object indicates the type picked from the [`Id`](https://docs.angular-package.dev/error/generic-type-variables#errors-less-than-id-greater-than) and its exact type is useful in picking the specific error from the storage.

### Parameters

#### `id:`[<mark style="color:green;">`ErrorId`</mark>](#erroridextendsid)

The [unique identification](https://docs.angular-package.dev/error/getting-started/basic-concepts#unique-identification) number of generic type variable [`ErrorId`](#erroridextendsid) to pick an error from the object.

### Return type

#### `Error<`[<mark style="color:green;">`ErrorId`</mark>](#erroridextendsid)`> |`[<mark style="color:green;">`undefined`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#null-and-undefined)

The **return type** is the [`Error`](https://docs.angular-package.dev/error/error) object that takes the generic type variable [`ErrorId`](#erroridextendsid) or [`undefined`](https://www.typescriptlang.org/docs/handbook/basic-types.html#null-and-undefined).

### Returns

The **return value** is the [`Error`](https://docs.angular-package.dev/error/typeerror) instance of the given [`id`](#id-errorid) if set, otherwise [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined).

## Example usage

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

// Define general errors.
const generalErrors = new Errors('EG: 4332', 'EG: 4331', 'EG: 4330');

// Set the `Error` objects under the given identification numbers.
generalErrors
  .set(
    'Bad parameter type, detected number',
    'Provide proper type, the `string`',
    'EG: 4330'
  )
  .set('Detected numbers', 'Provide only letters', 'EG: 4331');

// Returns the Error<"EG: 4330">.
generalErrors.get('EG: 4330');
```
