mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 23:36:16 -04:00
Add more helpful error for when numerical ingredient is left empty
This commit is contained in:
parent
1bc88728f0
commit
9606da7648
1 changed files with 3 additions and 3 deletions
|
@ -99,8 +99,6 @@ class Ingredient {
|
||||||
* @param {string} type - The name of the data type.
|
* @param {string} type - The name of the data type.
|
||||||
*/
|
*/
|
||||||
static prepare(data, type) {
|
static prepare(data, type) {
|
||||||
let number;
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "binaryString":
|
case "binaryString":
|
||||||
case "binaryShortString":
|
case "binaryShortString":
|
||||||
|
@ -116,7 +114,9 @@ class Ingredient {
|
||||||
}
|
}
|
||||||
case "number":
|
case "number":
|
||||||
if (data === null) return data;
|
if (data === null) return data;
|
||||||
number = parseFloat(data);
|
if (isNaN(data)) throw "Ingredient can not be empty.";
|
||||||
|
|
||||||
|
let number = parseFloat(data);
|
||||||
if (isNaN(number)) {
|
if (isNaN(number)) {
|
||||||
const sample = Utils.truncate(data.toString(), 10);
|
const sample = Utils.truncate(data.toString(), 10);
|
||||||
throw "Invalid ingredient value. Not a number: " + sample;
|
throw "Invalid ingredient value. Not a number: " + sample;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue