Make sure all errors use the serializer set for the logger
This commit is contained in:
parent
1dda183a31
commit
210f5b01ec
@ -342,7 +342,8 @@ function incrementMapViews ({ metadataBackend }) {
|
||||
|
||||
mapConfigProvider.getMapConfig((err, mapConfig) => {
|
||||
if (err) {
|
||||
logger.warn(err, `ERROR: failed to increment mapview count for user '${user}'`);
|
||||
err.message = `Failed to increment mapview count for user '${user}'. ${err.message}`;
|
||||
logger.warn({ error: err });
|
||||
return next();
|
||||
}
|
||||
|
||||
@ -354,7 +355,8 @@ function incrementMapViews ({ metadataBackend }) {
|
||||
|
||||
metadataBackend.incMapviewCount(user, statTag, (err) => {
|
||||
if (err) {
|
||||
logger.warn(err, `ERROR: failed to increment mapview count for user '${user}'`);
|
||||
err.message = `Failed to increment mapview count for user '${user}'. ${err.message}`;
|
||||
logger.warn({ error: err });
|
||||
}
|
||||
|
||||
next();
|
||||
|
@ -10,7 +10,8 @@ module.exports = function setCacheChannelHeader () {
|
||||
|
||||
mapConfigProvider.getAffectedTables((err, affectedTables) => {
|
||||
if (err) {
|
||||
logger.warn(err, 'ERROR generating Cache Channel Header');
|
||||
err.message = `Error generating Cache Channel Header. ${err.message}`;
|
||||
logger.warn({ error: err });
|
||||
return next();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,8 @@ module.exports = function setCacheControlHeader ({
|
||||
|
||||
mapConfigProvider.getAffectedTables((err, affectedTables) => {
|
||||
if (err) {
|
||||
logger.warn(err, 'ERROR generating Cache Control Header');
|
||||
err.message = `Error generating Cache Control Header. ${err.message}`;
|
||||
logger.warn({ error: err });
|
||||
return next();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ module.exports = function errorMiddleware (/* options */) {
|
||||
const { logger } = res.locals;
|
||||
const errors = populateLimitErrors(Array.isArray(err) ? err : [err]);
|
||||
|
||||
logger.error({ errors });
|
||||
logger.error({ error: errors });
|
||||
|
||||
const errorResponseBody = {
|
||||
errors: errors.map(errorMessage),
|
||||
|
@ -14,7 +14,8 @@ module.exports = function incrementMapViewCount (metadataBackend) {
|
||||
req.profiler.done('incMapviewCount');
|
||||
|
||||
if (err) {
|
||||
logger.warn(err, `ERROR: failed to increment mapview count for user '${user}'`);
|
||||
err.message = `Failed to increment mapview count for user '${user}'. ${err.message}`;
|
||||
logger.warn({ error: err });
|
||||
}
|
||||
|
||||
next();
|
||||
|
@ -21,7 +21,8 @@ module.exports = function setLastModifiedHeader () {
|
||||
|
||||
mapConfigProvider.getAffectedTables((err, affectedTables) => {
|
||||
if (err) {
|
||||
logger.warn(err, 'ERROR generating Last Modified Header');
|
||||
err.message = `Error generating Last Modified Header. ${err.message}`;
|
||||
logger.warn({ error: err });
|
||||
return next();
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@ module.exports = function metrics ({ enabled, tags, metricsBackend }) {
|
||||
}
|
||||
|
||||
return function metricsMiddleware (req, res, next) {
|
||||
// FIXME: use parent logger as we don't want bind the error to the request
|
||||
// but we still want to know if an error is thrown
|
||||
const { logger } = res.locals;
|
||||
|
||||
res.on('finish', () => {
|
||||
|
@ -17,7 +17,8 @@ module.exports = function setSurrogateKeyHeader ({ surrogateKeysCache }) {
|
||||
|
||||
mapConfigProvider.getAffectedTables((err, affectedTables) => {
|
||||
if (err) {
|
||||
logger.warn(err, 'ERROR generating Surrogate Key Header');
|
||||
err.message = `Erros generating Surrogate Key Header. ${err.message}`;
|
||||
logger.warn({ error: err });
|
||||
return next();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ module.exports = class Logger {
|
||||
serializers: {
|
||||
request: requestSerializer,
|
||||
response: responseSerializer,
|
||||
errors: (errors) => errors.map((err) => errorSerializer(err))
|
||||
error: (error) => Array.isArray(error) ? error.map((err) => errorSerializer(err)) : [errorSerializer(error)]
|
||||
}
|
||||
};
|
||||
const dest = pino.destination({ sync: false }); // stdout
|
||||
|
@ -67,7 +67,7 @@ describe('turbo-carto regressions', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail for private tables', function (done) {
|
||||
it.only('should fail for private tables', function (done) {
|
||||
var cartocss = [
|
||||
'#private_table {',
|
||||
' marker-placement: point;',
|
||||
|
Loading…
Reference in New Issue
Block a user