Skip to content

Commit

Permalink
Updated error serialier
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
mcollina committed Jun 28, 2022
1 parent 9ae9fc0 commit 977dec0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/error-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Serializer {
} else {
/* eslint no-undef: "off" */
const integer = this.parseInteger(i)
if (Number.isNaN(integer)) {
if (Number.isNaN(integer) || !Number.isFinite(integer)) {
throw new Error(`The value "${i}" cannot be converted to an integer.`)
} else {
return '' + integer
Expand All @@ -53,8 +53,10 @@ class Serializer {

asNumber (i) {
const num = Number(i)
if (Number.isNaN(num) || !Number.isFinite(num)) {
if (Number.isNaN(num)) {
throw new Error(`The value "${i}" cannot be converted to a number.`)
} else if (!Number.isFinite(num)) {
return null
} else {
return '' + num
}
Expand Down

0 comments on commit 977dec0

Please sign in to comment.