@yipe/dice 0.2.23 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -312,6 +312,23 @@ const query = new DiceQuery(pmf);
312
312
  console.log("DPR:", query.mean());
313
313
  ```
314
314
 
315
+ ### Error Handling
316
+
317
+ `parse()` throws a `DiceParseError` (a subclass of `Error`) for invalid input.
318
+ Narrow with `instanceof` and inspect the offending `expression`:
319
+
320
+ ```ts
321
+ import { parse, DiceParseError } from "@yipe/dice";
322
+
323
+ try {
324
+ parse("d6@3");
325
+ } catch (err) {
326
+ if (err instanceof DiceParseError) {
327
+ console.warn(`Bad dice expression: ${err.expression}`);
328
+ }
329
+ }
330
+ ```
331
+
315
332
  ### Sneak Attack (Conditional Damage)
316
333
 
317
334
  Conditional damage ("once-per-turn damage riders") like Sneak Attack can be modeled easily: