nested options and using it
This commit is contained in:
@@ -187,7 +187,7 @@ function setErrorHeader(errors, statusCode, res) {
|
||||
};
|
||||
});
|
||||
|
||||
res.set('X-Tiler-Errors', JSON.stringify(errorsLog));
|
||||
res.set('X-Tiler-Errors', stringifyForLogs(errorsLog));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,13 +198,16 @@ function setErrorHeader(errors, statusCode, res) {
|
||||
*/
|
||||
function stringifyForLogs(object) {
|
||||
Object.keys(object).map(key => {
|
||||
const value = object[key];
|
||||
if (object instanceof Object) {
|
||||
stringifyForLogs(value);
|
||||
} else {
|
||||
if (typeof object[key] === 'object') {
|
||||
stringifyForLogs(object[key]);
|
||||
} else if (object[key] instanceof Array) {
|
||||
for (let element of object[key]) {
|
||||
stringifyForLogs(element);
|
||||
}
|
||||
} else if(typeof object[key] === 'string') {
|
||||
object[key] = object[key].replace(/[^a-zA-Z0-9]/g, ' ');
|
||||
}
|
||||
});
|
||||
|
||||
return JSON.stringify(object);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user