# getErrors()

## `Errors.prototype.getErrors()`

Returns an [`object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) of set errors, where the key is a [unique identification](https://error.angular-package.dev/getting-started/basic-concepts#unique-identification).

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

```typescript
public getErrors(): { [Key in Id]: Error<Key> | undefined } {
  return Object.fromEntries(this.errors.entries()) as any;
}
```

{% endcode %}

### Return type

#### `{ [`<mark style="color:green;">`Key`</mark>`in`[<mark style="color:green;">`Id`</mark>](https://error.angular-package.dev/generic-type-variables#errors-less-than-id-greater-than)`]: Error<`<mark style="color:green;">`Key`</mark>`> |`<mark style="color:green;">`undefined`</mark>` ``}`

A **return type** is an object of the [`Error`](https://error.angular-package.dev/error) objects or [`undefined`](https://www.typescriptlang.org/docs/handbook/basic-types.html#null-and-undefined) in the keys of generic type variable [`Id`](https://error.angular-package.dev/generic-type-variables#errors-less-than-id-greater-than).

### Returns

The **return value** is an [`object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) of set errors.

## 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:
/*
Returns
  {
    EG: 4330: ...,
    EG: 4331: ...
  }
  of type
  {
    "EG: 4332": Error<"EG: 4332">;
    "EG: 4331": Error<"EG: 4331">;
    "EG: 4330": Error<"EG: 4330">;
  }
*/
generalErrors.getErrors();
```


---

# 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/errors/methods/geterrors.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.
