# get()

## `Errors.prototype.get()`

Returns the [`Error`](/draft-5/error/overview.md) 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>](/draft-5/errors/generic-type-variables.md#errors-less-than-id-greater-than)

A generic type variable `ErrorId` constrained by the generic type variable [`Id`](/draft-5/errors/generic-type-variables.md#errors-less-than-id-greater-than) of the [`Errors`](/draft-5/errors/overview.md) object indicates the type picked from the [`Id`](/draft-5/errors/generic-type-variables.md#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](/draft-5/getting-started/basic-concepts.md#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`](/draft-5/error/overview.md) 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`](/draft-5/typeerror/overview.md) 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');
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://error.angular-package.dev/draft-5/errors/methods/get.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
