Skip to content

Commit db40788

Browse files
committed
changed the custom error class to embed the invalid card rank
1 parent 7f195fc commit db40788

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function getCardValue(card) {
1818
} else if (!isNaN(rank) && Number(rank) >= 2 && Number(rank) <= 9) {
1919
return Number(rank);
2020
} else {
21-
throw new Error("Invalid card rank");
21+
throw new Error('Invalid card rank: "${rank}"'); //rather than just "Invalid card rank" we can show the actual rank that was invalid
2222
}
2323

2424

@@ -84,7 +84,7 @@ try {
8484
console.assert(false, "Expected an error to be thrown for invalid card rank");
8585
} catch (e) {
8686
console.assert(
87-
e.message === "Invalid card rank",
87+
e.message === 'Invalid card rank: "${rank}"',
8888
`Expected error message to be "Invalid card rank" but got "${e.message}"`
8989
);
9090
}

0 commit comments

Comments
 (0)