improve the YouNeedAD error message
This commit is contained in:
parent
ac63642d3a
commit
f4fcb097c3
|
@ -65,7 +65,7 @@ export const getRollConf = (rollStr: string): RollConf => {
|
||||||
|
|
||||||
// If the dPts is not long enough, throw error
|
// If the dPts is not long enough, throw error
|
||||||
if (dPts.length < 2) {
|
if (dPts.length < 2) {
|
||||||
throw new Error('YouNeedAD');
|
throw new Error(`YouNeedAD_${rollStr}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill out the die count, first item will either be an int or empty string, short circuit execution will take care of replacing the empty string with a 1
|
// Fill out the die count, first item will either be an int or empty string, short circuit execution will take care of replacing the empty string with a 1
|
||||||
|
@ -153,7 +153,7 @@ export const getRollConf = (rollStr: string): RollConf => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rollConf.dieCount || !rollConf.dieSize) {
|
if (!rollConf.dieCount || !rollConf.dieSize) {
|
||||||
throw new Error('YouNeedAD');
|
throw new Error(`YouNeedAD_${rollStr}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
loggingEnabled && log(LT.LOG, `${getLoopCount()} Handling ${rollConf.type} ${rollStr} | Parsed Die Count: ${rollConf.dieCount}`);
|
loggingEnabled && log(LT.LOG, `${getLoopCount()} Handling ${rollConf.type} ${rollStr} | Parsed Die Count: ${rollConf.dieCount}`);
|
||||||
|
|
|
@ -15,10 +15,15 @@ export const translateError = (solverError: Error): [string, string] => {
|
||||||
// Translate the errorName to a specific errorMsg
|
// Translate the errorName to a specific errorMsg
|
||||||
switch (errorName) {
|
switch (errorName) {
|
||||||
case 'WholeDieCountSizeOnly':
|
case 'WholeDieCountSizeOnly':
|
||||||
errorMsg = 'Error: Die Size and Die Count must be whole numbers';
|
errorMsg = 'Error: Die Size and Die Count must be positive whole numbers';
|
||||||
break;
|
break;
|
||||||
case 'YouNeedAD':
|
case 'YouNeedAD':
|
||||||
errorMsg = 'Formatting Error: Missing die size and count config';
|
errorMsg = `Error: Attempted to parse \`${errorDetails}\` as a dice configuration, `;
|
||||||
|
if (errorDetails.includes('d')) {
|
||||||
|
errorMsg += '`d` was found, but the die size and/or count were missing or zero when they should be a positive whole number';
|
||||||
|
} else {
|
||||||
|
errorMsg += '`d` was not found in the dice config for specifying die size and/or count';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'CannotParseDieCount':
|
case 'CannotParseDieCount':
|
||||||
errorMsg = `Formatting Error: Cannot parse \`${errorDetails}\` as a number`;
|
errorMsg = `Formatting Error: Cannot parse \`${errorDetails}\` as a number`;
|
||||||
|
|
Loading…
Reference in New Issue