Open nesges opened 1 year ago
This is actually expected behaviour, because you can't roll 0
dice.
That error is the die parser failing because the syntax is invalid; The number of sides must be at least 1
.
What behaviour would you expect in this situation?
What behaviour would you expect in this situation?
Some kind of human readable message like "you can't roll 0 dice" would be better error handling.
I'm using rpg-dice-roller in a very simple service for a mastodon dice roller bot (https://codeberg.org/nesges/rollbot-mastodon/src/branch/main/server/server.js) and users try funny things
It's nice to see someone implementing it on Mastodon! Really cool.
You make a good point about the readability. I've been having a think about it and, at the core it's difficult to make those errors really nice, because they're thrown by the grammar parser library, Peggy. And, before it's been parsed, it's not easy to reliably tell if the notation is invalid.
However, I've just been looking over the Peggy docs, and it looks like the error messages can be enhanced slightly by naming the grammar rules. Most of the rules currently aren't annotated. I've had a quick play around, but haven't got a result I'm happy with
PRs are always appreciated.
Description
dice roller crashes on 0d. roller (CLI) throws a stacktrace:
Dice Roller version
v5.3.2
Bundle type
UMD
Node version
v16.20.0
Browser name and version
No response