Skip to content

Commit

Permalink
🐛 fix usages of logError (#8138)
Browse files Browse the repository at this point in the history
no issue
  • Loading branch information
kirrg001 authored and ErisDS committed Mar 13, 2017
1 parent e060a4f commit ea0f696
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions core/server/admin/controller.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
});
};
14 changes: 12 additions & 2 deletions core/server/middleware/custom-redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var fs = require('fs-extra'),
_ = require('lodash'),
config = require('../config'),
errors = require('../errors'),
logging = require('../logging'),
utils = require('../utils');

/**
Expand All @@ -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;
}

Expand Down Expand Up @@ -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.'
}));
}
}
};

0 comments on commit ea0f696

Please sign in to comment.