Add additional checks when editing items or effects

This commit is contained in:
Johannes Loher 2021-02-11 12:03:32 +01:00
parent 965c7c3ecf
commit 2158026437
4 changed files with 21 additions and 4 deletions

View file

@ -92,8 +92,12 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Data<DS4Item>> {
case "create":
return this._createActiveEffect();
case "edit":
const effect = this.item.effects.get(li.data("effectId"));
return effect?.sheet.render(true);
const id = li.data("effectId");
const effect = this.item.effects.get(id);
if (!effect) {
throw new Error(game.i18n.format("DS4.ErrorItemDoesNotHaveEffect", { id, item: this.item.name }));
}
return effect.sheet.render(true);
case "delete": {
return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
}