Throw errors instead of returning reason

Throw errors instead of returning reason and throw errors if the entry has no root files
This commit is contained in:
Luis Tejeda
2022-06-06 15:58:09 -05:00
parent 2e73ed22bb
commit 4ccfa86271
3 changed files with 93 additions and 22 deletions

View File

@@ -4921,26 +4921,23 @@ module.exports = {
try {
res.output.data = this.mapProcessRelatedFiles(inputRelatedFiles.rootFiles, inputRelatedFiles.data,
inputRelatedFiles.origin, version, inputRelatedFiles.bundleFormat, toBundle);
if (res.output.data === undefined || res.output.data.result === false ||
res.output.data.length === 0) {
res.result = false;
}
}
catch (error) {
if (error instanceof ParseError) {
return {
result: false,
reason: error.message
};
}
else {
throw (error);
}
}
if (res.output.data.result === false) {
res.result = res.output.data.result;
res.error = res.output.data.error;
let newError = new Error('There was an error during the process');
newError.stack = error.stack;
throw (newError);
}
return res;
}
else {
return res;
throw new Error('Input should have at least one root file');
}
},