From 215c2cd2b2d944ff53385e20bc134e98e15f25c8 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Tue, 23 May 2017 13:38:48 +0700 Subject: [PATCH] Prepend option names with opts. in error messages --- src/index.js | 4 ++-- test/b64.decode.js | 2 +- test/b64.encode.js | 2 +- test/b64.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index f8d2789..39077e3 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,7 @@ const validateOpts = (opts, chunkMultiple) => { opts.chunkSize = Math.ceil(opts.chunkSize / chunkMultiple) * chunkMultiple; if (opts.chunkSize === 0) { - throw new Error('chunkSize must be larger than 0'); + throw new Error('opts.chunkSize must be larger than 0'); } return opts; @@ -17,7 +17,7 @@ const b64 = (input, opts) => { return b64[opts.method](input, opts); } - return Promise.reject(new Error('method must be \'encode\' or \'decode\'.')); + return Promise.reject(new Error('opts.method must be \'encode\' or \'decode\'.')); }; b64.encode = (input, opts) => new Promise(resolve => { diff --git a/test/b64.decode.js b/test/b64.decode.js index b123b11..c20e85e 100644 --- a/test/b64.decode.js +++ b/test/b64.decode.js @@ -31,7 +31,7 @@ test('b64.decode rounds chunks up to multiples of 4', async t => { test('b64.decode rejects Promise if chunkSize is 0', async t => { const error = await t.throws(b64.decode(values.string, { chunkSize: 0 })); - t.is(error.message, 'chunkSize must be larger than 0'); + t.is(error.message, 'opts.chunkSize must be larger than 0'); }); test('b64.decode rejects Promise if input is not a string', async t => { diff --git a/test/b64.encode.js b/test/b64.encode.js index 99bb3ec..c21be8e 100644 --- a/test/b64.encode.js +++ b/test/b64.encode.js @@ -28,7 +28,7 @@ test('b64.encode rounds chunks up to multiples of 3', async t => { test('b64.encode rejects Promise if chunkSize is 0', async t => { const error = await t.throws(b64.encode(values.buffer, { chunkSize: 0 })); - t.is(error.message, 'chunkSize must be larger than 0'); + t.is(error.message, 'opts.chunkSize must be larger than 0'); }); test('b64.encode rejects Promise if input is not a buffer', async t => { diff --git a/test/b64.js b/test/b64.js index abfed7b..9c3af5b 100644 --- a/test/b64.js +++ b/test/b64.js @@ -16,5 +16,5 @@ test('b64 calls b64[opts.method]', async t => { test('b64 rejects Promise if method is not \'encode\' or \'decode\'', async t => { const error = await t.throws(b64(values.buffer)); - t.is(error.message, 'method must be \'encode\' or \'decode\'.'); + t.is(error.message, 'opts.method must be \'encode\' or \'decode\'.'); });