javalent / dice-roller

Inline dice rolling for Obsidian.md
265 stars 27 forks source link

Dice Roller stops working after it encountered a parsing error in a formula #300

Open vonloxley opened 4 months ago

vonloxley commented 4 months ago

Check for existing bug reports before submitting.

Expected Behavior

I made an error in a formula, like forgetting to put the last needed term into a formula. Ex.: 2d10<. I’d like Dice Roller to either notify me about my error or do nothing until I corrected the error.

Current behaviour

Dice Roller stops working entirely and needs to be disabled and enabled again. Th econsole shows:

Error: invalid syntax at line 1 col 5:

  2d10<
      ^
    at y._token (VM228 plugin:obsidian-dice-roller:16:319)
    at y.next (VM228 plugin:obsidian-dice-roller:15:1538)
    at _.next (VM228 plugin:obsidian-dice-roller:16:572)
    at Function.from (<anonymous>)
    at na.parse (VM228 plugin:obsidian-dice-roller:3528:245783)
    at n0.parse (VM228 plugin:obsidian-dice-roller:3536:6345)
    at n0.getRollerSync (VM228 plugin:obsidian-dice-roller:3536:5153)
    at enter (VM228 plugin:obsidian-dice-roller:3528:247393)
    at e.iterate (app.js:1:553855)
    at ju.iterate (app.js:1:2037967)

Reproduction

  1. Start writing a dice-mod block: but don’t finish it: `dice-mod: 2d10<.
  2. Close the block: `.

Which Operating Systems are you using?

Obsidian Version Check

1.5.8 and 1.5.3

Plugin Version

10.4.5

Confirmation

Possible solution

Catch the invalid syntax error. Optionally notify the user.