mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05: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
4e69f24964
commit
a2f9204069
1 changed files with 6 additions and 3 deletions
|
@ -84,7 +84,8 @@ module.exports = class PackageJson {
|
||||||
try {
|
try {
|
||||||
source = await fs.readFile(path);
|
source = await fs.readFile(path);
|
||||||
} catch (readError) {
|
} 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.context = path;
|
||||||
err.err = readError;
|
err.err = readError;
|
||||||
|
|
||||||
|
@ -94,7 +95,8 @@ module.exports = class PackageJson {
|
||||||
try {
|
try {
|
||||||
json = JSON.parse(source);
|
json = JSON.parse(source);
|
||||||
} catch (parseError) {
|
} 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.context = path;
|
||||||
err.err = parseError;
|
err.err = parseError;
|
||||||
err.help = this.i18n.t('errors.utils.parsepackagejson.willBeRequired', {url: 'https://ghost.org/docs/themes/'});
|
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;
|
const hasRequiredKeys = json.name && json.version;
|
||||||
|
|
||||||
if (!hasRequiredKeys) {
|
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.context = path;
|
||||||
err.help = this.i18n.t('errors.utils.parsepackagejson.willBeRequired', {url: 'https://ghost.org/docs/themes/'});
|
err.help = this.i18n.t('errors.utils.parsepackagejson.willBeRequired', {url: 'https://ghost.org/docs/themes/'});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue