Created
September 12, 2018 15:18
-
-
Save fabiobusnello/617d047e258d987ac828e7fc95e5e1ab to your computer and use it in GitHub Desktop.
ERRORS express
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const moment = require('moment') | |
const errors = (err, res) => { | |
if(!err)return false | |
const logName = moment().format('DD_MM_YYYY-HH_mm_ss_SSS') + '.txt' | |
if(res){ | |
res.status(500).json({status: false, message: "Erro interno no servidor, log disponível apneas no servidor em /logs/errors/DATA_HORA_MILLESEGUNDOS.txt"}) | |
} | |
fs.writeFile(__dirname + '/../logs/errors/' + logName, err.stack || err, err=>{ | |
if(err)return console.log(err) | |
}) | |
} | |
module.exports = errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment