Skip to content

Commit

Permalink
Prepend option names with opts. in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechilds committed May 23, 2017
1 parent cfcfea7 commit 215c2cd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Expand Up @@ -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;
Expand All @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion test/b64.decode.js
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion test/b64.encode.js
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion test/b64.js
Expand Up @@ -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\'.');
});

0 comments on commit 215c2cd

Please sign in to comment.