# @banxware/simple-error

> A simple repository for error handling.

Latest version **1.15.0** (published 2025-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @banxware/simple-error
pnpm add @banxware/simple-error
yarn add @banxware/simple-error
bun add @banxware/simple-error
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.15.0 |
| Published | 2025-07-28 |
| First published | 2022-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 36.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Banxware GmbH |
| Maintainers | dvarela, sergei-konovalov-banxware, guilherme.oliveira, fheiss_bxw, banxwareinvoice |

## Links

- npm: https://www.npmjs.com/package/@banxware/simple-error
- npm.io page: https://npm.io/package/@banxware/simple-error

## Recent versions

- 1.15.0 (latest) — 2025-07-28
- 1.14.0 — 2025-07-11
- 1.13.0 — 2025-07-07
- 1.12.0 — 2025-07-02
- 1.11.0 — 2025-06-27
- 1.10.0 — 2025-06-12
- 1.9.0 — 2025-05-28
- 1.8.0 — 2025-05-22
- 1.7.0 — 2025-05-13
- 1.6.0 — 2025-05-12
- 1.5.0 — 2025-05-02
- 1.4.0 — 2025-04-28
- 1.3.0 — 2022-12-28
- 1.2.0 — 2022-12-27
- 1.1.0 — 2022-12-19

## README

# Simple Errors

## Description

Tired of creating the errors over and over again in different repos?
Pissed of on how inconsistent they can be?
Your problems are now over! 
With the super duper uper simple errors this problem is now solved.

## Install

```
$ npm i @banxware/simple-error
```

## Usage


```ts
const myHandler = (event: APIGatewayProxyEvent, context: Context): Promise<APIGatewayProxyResult> => {
  try {
    // your busines logic goes here
    
  } catch(error) {
    toApiGatewayErrorResponse(error)
  }
}
```

The `toApiGatewayErrorResponse` function will convert all responses to a common response. If it is comming from axios
it will convert with the correct status code and the message sent by the downstream service. If you are using simple-repository,
404s will be handled as well. Every non-handled error will be treated as a 500 - Internal Server Error.


## Extending

In case you want to implement some custom internal errors, you have two options: 
1. You can extend CustomError
2. You can extend BanxwareApiGatewayError

Both errors will be interpreted by the toApiGatewayErrorResponse. The difference is the second one will enforce
the status code and it is more suitable for http/rest errors.

---
_Source: https://npm.io/package/@banxware/simple-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
