2.0.1 • Published 1 year ago

jochong-exception v2.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year 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

1 year ago

2.0.0

1 year ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

1.0.0

2 years ago