0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added Promise.reject to importer error cases

no issue
This commit is contained in:
Daniel Lockyer 2020-04-08 15:19:03 +01:00
parent 294187c41f
commit 48fe7b0bc7

View file

@ -51,26 +51,26 @@ DataImporter = {
}
if (!importData.meta) {
throw new common.errors.IncorrectUsageError({
return Promise.reject(new common.errors.IncorrectUsageError({
message: 'Wrong importer structure. `meta` is missing.',
help: 'https://ghost.org/docs/api/migration/#json-file-structure'
});
}));
}
if (!importData.meta.version) {
throw new common.errors.IncorrectUsageError({
return Promise.reject(new common.errors.IncorrectUsageError({
message: 'Wrong importer structure. `meta.version` is missing.',
help: 'https://ghost.org/docs/api/migration/#json-file-structure'
});
}));
}
// CASE: We deny LTS imports, because these are major version jumps. Only imports from v1 until the latest are supported.
// We can detect a wrong structure by checking the meta version field. Ghost v0 doesn't use semver compliant versions.
if (!semver.valid(importData.meta.version)) {
throw new common.errors.IncorrectUsageError({
return Promise.reject(new common.errors.IncorrectUsageError({
message: 'Detected unsupported file structure.',
help: 'Please install Ghost 1.0, import the file and then update your blog to the latest Ghost version.\nVisit https://ghost.org/update/?v=0.1 or ask for help in our https://forum.ghost.org.'
});
}));
}
this.init(importData);