# jochong-exception

> exception class for jochong

Latest version **2.0.1** (published 2024-01-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install jochong-exception
pnpm add jochong-exception
yarn add jochong-exception
bun add jochong-exception
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2024-01-20 |
| First published | 2023-11-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | jochong |
| Maintainers | jo_chong |

## Links

- npm: https://www.npmjs.com/package/jochong-exception
- Repository: https://github.com/jochongs/jochong-exception
- Homepage: https://github.com/jochongs/jochong-exception#readme
- Issues: https://github.com/jochongs/jochong-exception/issues
- npm.io page: https://npm.io/package/jochong-exception

## Recent versions

- 2.0.1 (latest) — 2024-01-20
- 2.0.0 — 2024-01-20
- 1.3.0 — 2023-12-25
- 1.2.0 — 2023-11-19
- 0.0.10 — 2023-11-17
- 0.0.8 — 2023-11-16
- 0.0.7 — 2023-11-16
- 0.0.6 — 2023-11-16
- 0.0.5 — 2023-11-15
- 0.0.4 — 2023-11-15

## README

## Jochong Exception

### Usage

```bash
npm i jochong-exception
```

You can create HTTP exception.

The second parameter is a place for error.

```javascript
const { BadRequestException } = require('jochong-exception');

new BadRequestException('title');
```

```javascript
const { InternalServerErrorException } = require('jochong-exception');

if (err) {
    // include err
    return new InternalServerErrorException('Unexpected Error Occured.', err);
}
```

```javascript
return new BadRequestException({ reason: 'email' });
```
Also, the first parameter may contain an object.

When inserting a character string, you can receive a response with a 'message' as a key value.

### In Express
```javascript
const { BadRequestException, Exception } = require('jochong-exception');
const app = express();

app.use((err, req, res, next) => {
    if (err instanceof Exception) {
        res.status(err.status).send(err.response);
    }

    // Do Something...
});
```
Never forget that there is an error in HTTP exception instance.

Never send an error to the client.

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