diff options
| author | Adam Soltys <[email protected]> | 2020-12-16 19:20:44 -0500 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-12-16 19:21:10 -0500 |
| commit | 64ed7a0153528ed55c53b8469d7d9266ac280ec3 (patch) | |
| tree | 63b080c6b12e9c71cc969c0043c42b7ed0d1b1cb /index.js | |
| parent | 9b1820ae3c7c33e3827258eeef987d4a89122d34 (diff) | |
| download | coinos-server-64ed7a0153528ed55c53b8469d7d9266ac280ec3.tar.gz coinos-server-64ed7a0153528ed55c53b8469d7d9266ac280ec3.zip | |
separate json error
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -32,6 +32,24 @@ app = express(); app.enable("trust proxy"); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); +app.use((err, req, res, next) => { + const details = { + path: req.path, + body: req.body, + msg: err.message, + stack: err.stack + }; + + if (req.user) details.username = req.user.username; + + l.error("JSON Error: ", details); + res.status(500); + res.set({ + "Cache-Control": "no-cache" + }); + res.send(err.message); + return res.end(); +}); app.use(cookieParser()); app.use(cors({ credentials: true, origin: "http://*:*" })); app.use(compression()); @@ -69,7 +87,7 @@ app.use((err, req, res, next) => { if (req.user) details.username = req.user.username; - // l.error("Error: ", details); + l.error("Error: ", details); res.status(500); res.set({ "Cache-Control": "no-cache" |
