mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-26 14:32:04 -04:00
better error logging
This commit is contained in:
parent
b10903b7f1
commit
066c838d8c
@ -5,6 +5,7 @@ import fs from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {buildDict, buildList} from "./src/helpers";
|
import {buildDict, buildList} from "./src/helpers";
|
||||||
import buildLocaleList from "./src/buildLocaleList";
|
import buildLocaleList from "./src/buildLocaleList";
|
||||||
|
import formatError from './src/error';
|
||||||
|
|
||||||
const config = loadSuml('config');
|
const config = loadSuml('config');
|
||||||
const translations = loadSuml('translations');
|
const translations = loadSuml('translations');
|
||||||
@ -148,7 +149,7 @@ export default {
|
|||||||
{ src: '~/plugins/globals.js' },
|
{ src: '~/plugins/globals.js' },
|
||||||
{ src: '~/plugins/auth.js' },
|
{ src: '~/plugins/auth.js' },
|
||||||
{ src: '~/plugins/datepicker.js', ssr: false },
|
{ src: '~/plugins/datepicker.js', ssr: false },
|
||||||
{ src: '~/plugins/track.js', ssr: false }
|
{ src: '~/plugins/track.js', ssr: false },
|
||||||
],
|
],
|
||||||
components: true,
|
components: true,
|
||||||
buildModules: [],
|
buildModules: [],
|
||||||
@ -399,4 +400,16 @@ export default {
|
|||||||
routes.push({ name: 'all', path: `*`, component: resolve(__dirname, 'routes/pronoun.vue') });
|
routes.push({ name: 'all', path: `*`, component: resolve(__dirname, 'routes/pronoun.vue') });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
hooks: {
|
||||||
|
render: {
|
||||||
|
errorMiddleware(app) {
|
||||||
|
app.use((err, req, res, next) => {
|
||||||
|
if (err) {
|
||||||
|
console.error(formatError(err, req));
|
||||||
|
}
|
||||||
|
next(err);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import cookieSettings from "../src/cookieSettings";
|
|||||||
import SQL from "sql-template-strings";
|
import SQL from "sql-template-strings";
|
||||||
import csurf from 'csurf'
|
import csurf from 'csurf'
|
||||||
import csrfHandleError from "@privyid/nuxt-csrf/server-middleware/handle-error";
|
import csrfHandleError from "@privyid/nuxt-csrf/server-middleware/handle-error";
|
||||||
|
import formatError from '../src/error';
|
||||||
|
|
||||||
global.config = loadSuml('config');
|
global.config = loadSuml('config');
|
||||||
global.translations = loadSuml('translations');
|
global.translations = loadSuml('translations');
|
||||||
@ -117,7 +118,7 @@ app.use(require('./routes/translations').default);
|
|||||||
app.use(require('./routes/subscription').default);
|
app.use(require('./routes/subscription').default);
|
||||||
|
|
||||||
app.use(function (err, req, res, next) {
|
app.use(function (err, req, res, next) {
|
||||||
console.error(err.stack);
|
console.error(formatError(err, req));
|
||||||
res.status(500).send('Unexpected server error');
|
res.status(500).send('Unexpected server error');
|
||||||
req.db.close();
|
req.db.close();
|
||||||
});
|
});
|
||||||
|
3
src/error.js
Normal file
3
src/error.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = (err, req) => {
|
||||||
|
return `[${new Date().toISOString()}][${req ? (req.method + ' ' + req.url) : ''}] ${err.message || err} ${err.stack}`;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user