guilima / financial-back

Node API structure connection to postgreSQL / redis
MIT License
4 stars 0 forks source link

feat(middleware): Add errorHandler and .on('error') callback as error logger #11

Closed guilima closed 4 years ago

guilima commented 4 years ago

Method errorHandler as middleware. Include ctx.app.emit('error') to log sensitive application error information (stack trace) into a file, database, kibana or any other log service. Start to use ctx.throw for formatted exceptions by http status code.

resolves #5

references: koajs error-handling 4 Chapter - Handling errors in Koa node api schema validation with joi toptal java error-handling padronização de resposta de erro em APIs standardized response bodies (RFC 7807) RF7807 (custom classes HttpException)[https://github.com/GoldL/island/blob/master/core/http-exception.js]