mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Changed app/loader to use @tryghost/errors
- getting rid of instances of new Error as we should always use @tryghost/errors
- Whilst here, got rid of i18n but discovered the messages were missing!
- This is my fault, they disappeared when I removed external apps and clearly removed too much: 8c1a0b8d0c (diff-0f5cc40aa8906a1be1bad2002a35361bbf9e766e46b3b29be10f4f479265426a)
- Therefore, I have restored these messages in the places where they were used, except amp_content, where I have written a new message, as the message that was there was not relevant
This commit is contained in:
parent
df51da5f7e
commit
ac07703f17
3 changed files with 20 additions and 8 deletions
|
@ -9,7 +9,7 @@
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
|
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const {SafeString, logging, i18n, errors} = require('../../../../services/proxy');
|
const {SafeString, logging, errors} = require('../../../../services/proxy');
|
||||||
const amperizeCache = {};
|
const amperizeCache = {};
|
||||||
let allowedAMPTags = [];
|
let allowedAMPTags = [];
|
||||||
let allowedAMPAttributes = {};
|
let allowedAMPAttributes = {};
|
||||||
|
@ -128,11 +128,11 @@ function getAmperizeHTML(html, post) {
|
||||||
if (err.src) {
|
if (err.src) {
|
||||||
// This is a valid 500 GhostError because it means the amperize parser is unable to handle some Ghost HTML.
|
// This is a valid 500 GhostError because it means the amperize parser is unable to handle some Ghost HTML.
|
||||||
logging.error(new errors.GhostError({
|
logging.error(new errors.GhostError({
|
||||||
message: `AMP HTML couldn't get parsed: ${err.src}`,
|
message: `AMP HTML couldn't be parsed: ${err.src}`,
|
||||||
code: 'AMP_PARSER_ERROR',
|
code: 'AMP_PARSER_ERROR',
|
||||||
err: err,
|
err: err,
|
||||||
context: post.url,
|
context: post.url,
|
||||||
help: i18n.t('errors.apps.appWillNotBeLoaded.help')
|
help: 'Please share this error on GitHub or https://forum.ghost.org'
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
logging.error(new errors.GhostError({err, code: 'AMP_PARSER_ERROR'}));
|
logging.error(new errors.GhostError({err, code: 'AMP_PARSER_ERROR'}));
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
const debug = require('@tryghost/debug')('services:apps');
|
const debug = require('@tryghost/debug')('services:apps');
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const i18n = require('../../../shared/i18n');
|
const tpl = require('@tryghost/tpl');
|
||||||
const logging = require('@tryghost/logging');
|
const logging = require('@tryghost/logging');
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const config = require('../../../shared/config');
|
const config = require('../../../shared/config');
|
||||||
const loader = require('./loader');
|
const loader = require('./loader');
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
appWillNotBeLoadedError: 'The app will not be loaded',
|
||||||
|
appWillNotBeLoadedHelp: 'Check with the app creator, or read the app documentation for more details on app requirements'
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: function () {
|
init: function () {
|
||||||
debug('init begin');
|
debug('init begin');
|
||||||
|
@ -15,8 +20,8 @@ module.exports = {
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
logging.error(new errors.GhostError({
|
logging.error(new errors.GhostError({
|
||||||
err: err,
|
err: err,
|
||||||
context: i18n.t('errors.apps.appWillNotBeLoaded.error'),
|
context: tpl(messages.appWillNotBeLoadedError),
|
||||||
help: i18n.t('errors.apps.appWillNotBeLoaded.help')
|
help: tpl(messages.appWillNotBeLoadedHelp)
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const i18n = require('../../../shared/i18n');
|
const errors = require('@tryghost/errors');
|
||||||
|
const tpl = require('@tryghost/tpl');
|
||||||
const config = require('../../../shared/config');
|
const config = require('../../../shared/config');
|
||||||
const Proxy = require('./proxy');
|
const Proxy = require('./proxy');
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
noActivateMethodLoadingAppError: 'Error loading app named {name}; no activate() method defined.'
|
||||||
|
};
|
||||||
|
|
||||||
// Get the full path to an app by name
|
// Get the full path to an app by name
|
||||||
function getAppAbsolutePath(name) {
|
function getAppAbsolutePath(name) {
|
||||||
return path.join(config.get('paths').internalAppPath, name);
|
return path.join(config.get('paths').internalAppPath, name);
|
||||||
|
@ -35,7 +40,9 @@ module.exports = {
|
||||||
|
|
||||||
// Check for an activate() method on the app.
|
// Check for an activate() method on the app.
|
||||||
if (!_.isFunction(app.activate)) {
|
if (!_.isFunction(app.activate)) {
|
||||||
return Promise.reject(new Error(i18n.t('errors.apps.noActivateMethodLoadingApp.error', {name: name})));
|
return Promise.reject(new errors.IncorrectUsageError(
|
||||||
|
tpl(messages.noActivateMethodLoadingAppError, {name: name})
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapping the activate() with a when because it's possible
|
// Wrapping the activate() with a when because it's possible
|
||||||
|
|
Loading…
Reference in a new issue