add new error to catch [[floor1_1d3]] and error out correctly
This commit is contained in:
parent
ac8602f598
commit
6b198ecb47
|
@ -288,7 +288,9 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
|
||||||
// Welp, the unthinkable happened, we hit an error
|
// Welp, the unthinkable happened, we hit an error
|
||||||
|
|
||||||
// Split on _ for the error messages that have more info than just their name
|
// Split on _ for the error messages that have more info than just their name
|
||||||
const [errorName, errorDetails] = solverError.message.split('_');
|
const errorSplits = solverError.message.split('_');
|
||||||
|
const errorName = errorSplits.shift();
|
||||||
|
const errorDetails = errorSplits.join('_');
|
||||||
|
|
||||||
let errorMsg = '';
|
let errorMsg = '';
|
||||||
|
|
||||||
|
@ -300,6 +302,9 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
|
||||||
case 'YouNeedAD':
|
case 'YouNeedAD':
|
||||||
errorMsg = 'Formatting Error: Missing die size and count config';
|
errorMsg = 'Formatting Error: Missing die size and count config';
|
||||||
break;
|
break;
|
||||||
|
case 'CannotParseDieCount':
|
||||||
|
errorMsg = `Formatting Error: Cannot parse \`${errorDetails}\` as a number`;
|
||||||
|
break;
|
||||||
case 'DoubleSeparator':
|
case 'DoubleSeparator':
|
||||||
errorMsg = `Formatting Error: \`${errorDetails}\` should only be specified once per roll, remove all but one and repeat roll`;
|
errorMsg = `Formatting Error: \`${errorDetails}\` should only be specified once per roll, remove all but one and repeat roll`;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -91,6 +91,8 @@ export const roll = (rollStr: string, modifiers: RollModifiers): RollSet[] => {
|
||||||
const rawDC = dPts.shift() || '1';
|
const rawDC = dPts.shift() || '1';
|
||||||
if (rawDC.includes('.')) {
|
if (rawDC.includes('.')) {
|
||||||
throw new Error('WholeDieCountSizeOnly');
|
throw new Error('WholeDieCountSizeOnly');
|
||||||
|
} else if (rawDC.match(/\D/)) {
|
||||||
|
throw new Error(`CannotParseDieCount_${rawDC}`);
|
||||||
}
|
}
|
||||||
const tempDC = rawDC.replace(/\D/g, '');
|
const tempDC = rawDC.replace(/\D/g, '');
|
||||||
// Rejoin all remaining parts
|
// Rejoin all remaining parts
|
||||||
|
|
Loading…
Reference in New Issue