Skip to content

Commit

Permalink
Allow error properties to be string[] and number[]
Browse files Browse the repository at this point in the history
  • Loading branch information
mantoni committed Jul 4, 2024
1 parent e6c62ea commit d13bc34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fail.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

/**
* @typedef {Record<string, string | number | boolean | null>} FailureProperties
* @typedef {Record<string, string | string[] | number | number[] | boolean | null>} FailureProperties
*/

/**
Expand Down
12 changes: 12 additions & 0 deletions test/failure.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ describe('failure', () => {
assert.isUndefined(error.cause);
});

it('supports string arrays as error properties', () => {
const error = failure('Oups!', INVALID, { some: ['a', 'b'] });

assert.equals(error.properties, { some: ['a', 'b'] });
});

it('supports number arrays as error properties', () => {
const error = failure('Oups!', INVALID, { some: [1, 2] });

assert.equals(error.properties, { some: [1, 2] });
});

it('does not allow to change the error code', () => {
const error = failure('Oups!', INVALID);

Expand Down

0 comments on commit d13bc34

Please sign in to comment.