diff --git a/lib/errors.js b/lib/errors.js index 6aa605e..07b8501 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -121,6 +121,15 @@ class RenditionTooLarge extends ClientError { } } +// The rendition instructions were invalid +class RenditionInstructionError extends ClientError { + constructor(message) { + super(message, "RenditionInstructionError", Reason.RenditionInstructionError); + + Error.captureStackTrace(this, RenditionInstructionError); + } +} + module.exports = { GenericError, @@ -131,5 +140,6 @@ module.exports = { SourceUnsupportedError, SourceCorruptError, RenditionTooLarge, + RenditionInstructionError, ArgumentError }; diff --git a/test/errors.test.js b/test/errors.test.js index 0443a55..1476812 100644 --- a/test/errors.test.js +++ b/test/errors.test.js @@ -21,7 +21,8 @@ const { SourceFormatUnsupportedError, SourceUnsupportedError, SourceCorruptError, - RenditionTooLarge + RenditionTooLarge, + RenditionInstructionError } = require('../lib/errors'); describe("errors", function() { @@ -98,4 +99,15 @@ describe("errors", function() { assert.equal(e.reason, Reason.RenditionTooLarge); } }); + it("RenditionInstructionError", function() { + try { + throw new RenditionInstructionError("hi ho"); + } catch (e) { + assert.ok(e instanceof ClientError); + assert.ok(e instanceof RenditionInstructionError); + assert.equal(e.name, "RenditionInstructionError"); + assert.equal(e.message, "hi ho"); + assert.equal(e.reason, Reason.RenditionInstructionError); + } + }); });