roll-parser - v3.4.0
    Preparing search index...

    Class MockRNGExhaustedError

    Error thrown when a mock RNG runs out of predefined values.

    This is intentional behavior, not a limitation: a mock that wrapped around would silently pass a test whose expression rolls more dice than the author thought. Seeing this error means the notation consumed more draws than the sequence supplied — count the dice, including explosions, rerolls, and meta-expressions, and check the draw order in the roll-parser README.

    Deliberately outside the RollParserError hierarchy — no code, and isRollParserError answers false for it. An exhausted mock is a bug in the test fixture, not a failure mode of the notation, so the if (!isRollParserError(error)) throw error line a consumer writes around roll() rethrows it and fails the test instead of routing it to a "bad dice" message. instanceof is the check here — there is no code to branch on.

    import { roll } from 'roll-parser';
    import { createMockRng, MockRNGExhaustedError } from 'roll-parser/testing';

    try {
    roll('4d6', { rng: createMockRng([1, 2, 3]) });
    } catch (error) {
    error instanceof MockRNGExhaustedError; // true
    (error as MockRNGExhaustedError).consumed; // 3
    (error as Error).message;
    // 'MockRNG exhausted: consumed 3 values, no more available'
    }

    Hierarchy

    • Error
      • MockRNGExhaustedError
    Index
    consumed: number

    How many values the sequence handed out before running dry — equivalently, the length of the array that was passed to createMockRng. Compare it against the dice you expected to be rolled to find the miscount.