mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-26 13:35:16 +03:00
Changed Error
to IncorrectUsageError
in package-json
no issue - `Error` is very generic for this case and `IncorrectUsageError` will populate the resulting error with the correct error code - the `message` was pulled out to its own statement so we can avoid long lines
This commit is contained in:
parent
eea93d55f4
commit
95cfa97747
@ -84,7 +84,8 @@ module.exports = class PackageJson {
|
||||
try {
|
||||
source = await fs.readFile(path);
|
||||
} catch (readError) {
|
||||
const err = new Error(this.i18n.t('errors.utils.parsepackagejson.couldNotReadPackage'));
|
||||
const err = new errors.IncorrectUsageError();
|
||||
err.message = this.i18n.t('errors.utils.parsepackagejson.couldNotReadPackage');
|
||||
err.context = path;
|
||||
err.err = readError;
|
||||
|
||||
@ -94,7 +95,8 @@ module.exports = class PackageJson {
|
||||
try {
|
||||
json = JSON.parse(source);
|
||||
} catch (parseError) {
|
||||
const err = new Error(this.i18n.t('errors.utils.parsepackagejson.themeFileIsMalformed'));
|
||||
const err = new errors.IncorrectUsageError();
|
||||
err.message = this.i18n.t('errors.utils.parsepackagejson.themeFileIsMalformed');
|
||||
err.context = path;
|
||||
err.err = parseError;
|
||||
err.help = this.i18n.t('errors.utils.parsepackagejson.willBeRequired', {url: 'https://ghost.org/docs/themes/'});
|
||||
@ -105,7 +107,8 @@ module.exports = class PackageJson {
|
||||
const hasRequiredKeys = json.name && json.version;
|
||||
|
||||
if (!hasRequiredKeys) {
|
||||
const err = new Error(this.i18n.t('errors.utils.parsepackagejson.nameOrVersionMissing'));
|
||||
const err = new errors.IncorrectUsageError();
|
||||
err.message = this.i18n.t('errors.utils.parsepackagejson.nameOrVersionMissing');
|
||||
err.context = path;
|
||||
err.help = this.i18n.t('errors.utils.parsepackagejson.willBeRequired', {url: 'https://ghost.org/docs/themes/'});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user