Skip to content

Commit

Permalink
improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
shinnn committed Nov 18, 2014
1 parent 3003b4f commit d4134e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion array-to-sentence-cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function arrayToSentence(arr, options) {
'use strict';

if (!Array.isArray(arr)) {
throw new TypeError('Argument must be an array.');
throw new TypeError('First argument must be an array.');
}

if (arr.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion array-to-sentence.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ window.arrayToSentence = function arrayToSentence(arr, options) {
'use strict';

if (!Array.isArray(arr)) {
throw new TypeError('Argument must be an array.');
throw new TypeError('First argument must be an array.');
}

if (arr.length === 0) {
Expand Down
8 changes: 4 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ function runTest(description, main) {
);

t.throws(
main.bind(null), /TypeError/,
main.bind(null), /TypeError.*First argument/,
'should throw a type error when it takes no arguments.'
);

t.throws(
main.bind(null, arguments), /TypeError/,
main.bind(null, arguments), /TypeError.*First argument/,
'should throw a type error when the first argument is not an array.'
);

t.throws(
main.bind(null, [1, 2], {separator: 1}), /TypeError/,
main.bind(null, [1, 2], {separator: 1}), /TypeError.*must be a string/,
'should throw a type error when `separator` option is not a string.'
);

t.throws(
main.bind(null, [1, 2], {lastSeparator: ['']}), /TypeError/,
main.bind(null, [1, 2], {lastSeparator: ['']}), /TypeError.*must be a string/,
'should throw a type error when `lastSeparator` option is not a string.'
);
});
Expand Down

0 comments on commit d4134e8

Please sign in to comment.