diff --git a/index.js b/index.js index 6a3203a8..034f3c8b 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,8 @@ const { SourceFormatUnsupportedError, SourceUnsupportedError, SourceCorruptError, - RenditionTooLarge + RenditionTooLarge, + ServiceOverLoadError } = require('@adobe/asset-compute-commons'); // -----------------------< exports >----------------------------------- @@ -38,5 +39,6 @@ module.exports = { SourceFormatUnsupportedError, SourceUnsupportedError, SourceCorruptError, - RenditionTooLarge + RenditionTooLarge, + ServiceOverLoadError }; diff --git a/lib/shell/shellscript.js b/lib/shell/shellscript.js index c5836633..06ad77ae 100644 --- a/lib/shell/shellscript.js +++ b/lib/shell/shellscript.js @@ -141,6 +141,8 @@ function newScriptError(err, errorFile) { return new errors.SourceFormatUnsupportedError(errJson.message || err.message || err); case errors.Reason.SourceUnsupported: return new errors.SourceUnsupportedError(errJson.message || err.message || err); + case errors.Reason.ServiceOverLoad: + return new errors.ServiceOverLoadError(errJson.message || err.message || err); default: return new errors.GenericError(errJson.message || err.message || err, `${Action.name}_shellScript`); } diff --git a/test/shellscript.test.js b/test/shellscript.test.js index 523bff5b..76bc6034 100644 --- a/test/shellscript.test.js +++ b/test/shellscript.test.js @@ -372,6 +372,20 @@ describe("api.js (shell)", () => { ); }); + it("should handle error.json - ServiceOverLoad instanceof ClientError", async () => { + createScript("worker.sh", ` + echo '{ "reason": "ServiceOverLoad", "message": "too many requests" }' > $errorfile + exit 1 + `); + const scriptWorker = new ShellScriptWorker(testUtil.simpleParams()); + + await assert.rejects( + scriptWorker.processWithScript(mockSource(), mockRendition()), + // check that instanceof works + err => err instanceof ClientError + ); + }); + it("should handle error.json - malformed json", async () => { createScript("worker.sh", ` echo '{ "message": MALFORMED' > $errorfile