2.0.1 • Published 4 months ago

jochong-exception v2.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

Jochong Exception

Usage

npm i jochong-exception

You can create HTTP exception.

The second parameter is a place for error.

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

new BadRequestException('title');
const { InternalServerErrorException } = require('jochong-exception');

if (err) {
    // include err
    return new InternalServerErrorException('Unexpected Error Occured.', err);
}
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

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.

2.0.1

4 months ago

2.0.0

4 months ago

1.3.0

5 months ago

1.2.0

6 months ago

1.1.1

6 months ago

0.0.11

6 months ago

0.0.10

6 months ago

0.0.9

6 months ago

0.0.8

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago

1.0.0

6 months ago