From f190bdaa5c6f2cd50293f067ddc3d7c2f7bba332 Mon Sep 17 00:00:00 2001 From: Sudheendra Katikar Date: Wed, 24 Jan 2024 16:43:02 -0800 Subject: [PATCH 1/2] Add new error type: RenditionInstructionError --- lib/errors.js | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 }; From 5db6ace11287485d8d351cfcb33b9e077d05c7d1 Mon Sep 17 00:00:00 2001 From: Sudheendra Katikar Date: Wed, 24 Jan 2024 16:46:42 -0800 Subject: [PATCH 2/2] Add a test --- test/errors.test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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); + } + }); });