Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const {
SourceFormatUnsupportedError,
SourceUnsupportedError,
SourceCorruptError,
RenditionTooLarge
RenditionTooLarge,
ServiceOverLoadError
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note from adobe/asset-compute-commons#71, which may lead to changes here.

} = require('@adobe/asset-compute-commons');

// -----------------------< exports >-----------------------------------
Expand All @@ -38,5 +39,6 @@ module.exports = {
SourceFormatUnsupportedError,
SourceUnsupportedError,
SourceCorruptError,
RenditionTooLarge
RenditionTooLarge,
ServiceOverLoadError
};
2 changes: 2 additions & 0 deletions lib/shell/shellscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
Expand Down
14 changes: 14 additions & 0 deletions test/shellscript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down