Skip to content

Commit

Permalink
[Refactor] remove custom ValueError in favor of TypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
aks- committed Feb 2, 2024
1 parent 8572ab7 commit 3a0a12a
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 15 deletions.
3 changes: 1 addition & 2 deletions lib/parse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var utils = require('./utils');
var ValueError = require('./value-error');

var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
Expand Down Expand Up @@ -220,7 +219,7 @@ var normalizeParseOptions = function normalizeParseOptions(opts) {
}

if (opts.allowDots === false && opts.decodeDotInKeys === true) {
throw new ValueError('Provided combination is not valid: allowDots=false & decodeDotInKeys=true');
throw new TypeError('Provided combination is not valid: allowDots=false & decodeDotInKeys=true');
}

if (opts.decoder !== null && typeof opts.decoder !== 'undefined' && typeof opts.decoder !== 'function') {
Expand Down
3 changes: 1 addition & 2 deletions lib/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var getSideChannel = require('side-channel');
var utils = require('./utils');
var formats = require('./formats');
var ValueError = require('./value-error');
var has = Object.prototype.hasOwnProperty;

var arrayPrefixGenerators = {
Expand Down Expand Up @@ -217,7 +216,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
}

if (opts.allowDots === true && opts.encodeDotInKeys === false) {
throw new ValueError('Provided combination is not valid: allowDots=true & encodeDotInKeys=false');
throw new TypeError('Provided combination is not valid: allowDots=true & encodeDotInKeys=false');
}

var charset = opts.charset || defaults.charset;
Expand Down
9 changes: 0 additions & 9 deletions lib/value-error.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ test('parse()', function (t) {
{ allowDots: false, decodeDotInKeys: true }
);
}, {
name: 'ValueError',
name: 'TypeError',
message: 'Provided combination is not valid: allowDots=false & decodeDotInKeys=true'
}
);
Expand Down
2 changes: 1 addition & 1 deletion test/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ test('stringify()', function (t) {
);
}, {
message: 'Provided combination is not valid: allowDots=true & encodeDotInKeys=false',
name: 'ValueError'
name: 'TypeError'
}
);

Expand Down

0 comments on commit 3a0a12a

Please sign in to comment.