> For the complete documentation index, see [llms.txt](https://docs.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.angular-package.dev/error/errors/methods/geterrors.md).

# 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](/error/getting-started/basic-concepts.md#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>](/error/errors/generic-type-variables.md#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`](/error/error/overview.md) objects or [`undefined`](https://www.typescriptlang.org/docs/handbook/basic-types.html#null-and-undefined) in the keys of generic type variable [`Id`](/error/errors/generic-type-variables.md#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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.angular-package.dev/error/errors/methods/geterrors.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
