From ea0f696c4dd968924c21b5f1a5ffdcdbaec41e96 Mon Sep 17 00:00:00 2001 From: Katharina Irrgang Date: Mon, 13 Mar 2017 20:47:09 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20fix=20usages=20of=20logError?= =?UTF-8?q?=20(#8138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue --- core/server/admin/controller.js | 6 ++++-- core/server/middleware/custom-redirects.js | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/server/admin/controller.js b/core/server/admin/controller.js index 57d18ffb0e..c5b2614a13 100644 --- a/core/server/admin/controller.js +++ b/core/server/admin/controller.js @@ -1,8 +1,8 @@ var debug = require('debug')('ghost:admin:controller'), _ = require('lodash'), api = require('../api'), - logging = require('../logging'), updateCheck = require('../update-check'), + logging = require('../logging'), i18n = require('../i18n'); // Route: index @@ -34,5 +34,7 @@ module.exports = function adminController(req, res) { }); }).finally(function noMatterWhat() { res.render('default'); - }).catch(logging.logError); + }).catch(function (err) { + logging.error(err); + }); }; diff --git a/core/server/middleware/custom-redirects.js b/core/server/middleware/custom-redirects.js index 06856038fc..64c3261463 100644 --- a/core/server/middleware/custom-redirects.js +++ b/core/server/middleware/custom-redirects.js @@ -2,6 +2,7 @@ var fs = require('fs-extra'), _ = require('lodash'), config = require('../config'), errors = require('../errors'), + logging = require('../logging'), utils = require('../utils'); /** @@ -16,7 +17,13 @@ module.exports = function redirects(blogApp) { _.each(redirects, function (redirect) { if (!redirect.from || !redirect.to) { - errors.logError(null, 'Your redirects.json file is in a wrong format'); + logging.warn(new errors.IncorrectUsageError({ + message: 'One of your custom redirects is in a wrong format.', + level: 'normal', + help: JSON.stringify(redirect), + context: 'redirects.json' + })); + return; } @@ -46,7 +53,10 @@ module.exports = function redirects(blogApp) { }); } catch (err) { if (err.code !== 'ENOENT') { - errors.logAndThrowError(err, 'Your redirects.json is broken.', 'Check if your JSON is valid.'); + logging.error(new errors.IncorrectUsageError({ + message: 'Your redirects.json is broken.', + help: 'Check if your JSON is valid.' + })); } } };