1.0.3 • Published 4 months ago

@jtorm/error-handler v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

jTorm Error Handler

Install

npm install @jtorm/error-handler

Config

Add handlers to the error handler pool at the desired scope(s) defined in Winston RFC5424. The custom handler has to be a function. Next you can add the errorHandlerModel in your application in for example try/catch statements.

const myEmergErrorHandler = async (level, log) => {
    // do something
};

const { errorHandlerModel, errorHandlerPoolModel } = require('@jtorm/error-handler');

errorHandlerPoolModel.emerg.push(myEmergErrorHandler);

(async () => {
    try {
        // do something
    } catch (error) {
        await errorHandlerModel.emerg(error);
    }
})();

There is also a mail send action model available that accepts a .env variable ERROR_HANDLER with a from and to e-mail address:

ERROR_HANDLER={"from": "noreply@test.com", "to": "info@test.com"}

And you need to define the e-mail config with .env variable EMAIL that passes a config object to the nodemailer.createTransport method: https://www.npmjs.com/package/nodemailer

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago

0.0.4

9 months ago

0.0.3

2 years ago

0.0.2

2 years ago