vellum-monster icon indicating copy to clipboard operation
vellum-monster copied to clipboard

Errors do not fail gracefull.

Open rg-wood opened this issue 2 years ago • 0 comments

Actual behaviour: Errors in the component are fatal, and can cause the entire stat block to not appear.

For example, if the multiattack action points to a non-existent attack ID:

actions='[
          {
            "name": "Multiattack",
            "type": "multiattack",
            "description": "The princess makes two command attacks.",
            "multiAttacks": {
              "id": "claw",
              "number": 2
            }
          },
          {
            "name": "Command",
            "id": "command",
            "type": "ranged-or-melee-attack",
            "bonus": "+5",
            "reach": "5ft.",
            "range": "60ft.",
            "target": "one target",
            "damage": "1d8 + 5",
            "damageType": "slashing"
          }
        ]'

...it fails with the following error:

Uncaught (in promise) TypeError: attack is undefined
    _calculateMultiattack vellum-monster.js:380
    get maxAttackBonus vellum-monster.js:352
    get effectiveAttackBonus vellum-monster.js:317
    get calculatedCrs vellum-monster.js:312
    renderStats vellum-monster.js:127
    render vellum-stat-block.ts:114
    update lit-element.ts:300
    performUpdate updating-element.ts:775
    _enqueueUpdate updating-element.ts:725
    requestUpdateInternal updating-element.ts:690
    initialize updating-element.ts:531
    initialize lit-element.ts:224
    UpdatingElement updating-element.ts:516
    LitElement lit-element.ts:101
    StatBlock vellum-stat-block.ts:5
    Monster vellum-monster.js:13
    <anonymous> vellum-monster.js:405
vellum-monster.js:380:8

Expected behaviour: <vellum-monster> should recover and display as much information as is readable. Errors should be reported to the console.

rg-wood avatar Oct 30 '21 11:10 rg-wood