---
url: https://apexfluently.beyondthecloud.dev/libraries/lwc/error-service.md
description: >-
  Simplify LWC error handling. Convert various Salesforce error formats into
  user-friendly strings with reduceErrors function.
---

# Error Service

The reduceErrors function simplifies error handling by converting various Salesforce error formats into a single, user-friendly string.

## Why Error Service?

* **Handle Errors Automatically** - No matter if you pass an array, an object, or just a string, the error message will be reduced to a single string.

## Quick Start

```js
import { reduceErrors } from 'c/errorService';

try {
    // some code that may throw an error
} catch (error) {
    const errorMessage = reduceErrors(error);
    // Now you can display `errorMessage` to the user.
}
```

## Documentation

* [Github Repository](https://github.com/beyond-the-cloud-dev/lwc-utils)

## Installation

* [Copy and Deploy](https://github.com/beyond-the-cloud-dev/lwc-utils/tree/main/force-app/main/default/lwc/errorService)
