Added try catch construct to prevent error that was breaking reloadHelper tests

This commit is contained in:
Wlowscha 2025-01-05 02:40:28 +01:00
parent 2fc436f512
commit 5e565afaa4
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
1 changed files with 10 additions and 1 deletions

View File

@ -102,8 +102,17 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
this.unskippedIndices = this.getUnskippedIndices(options);
if (this.optionSelectText) {
this.optionSelectText.destroy();
if (this.optionSelectText instanceof BBCodeText) {
try {
this.optionSelectText.destroy();
} catch (error) {
console.error("Error while destroying optionSelectText:", error);
}
} else {
console.warn("optionSelectText is not an instance of BBCodeText.");
}
}
if (this.optionSelectIcons?.length) {
this.optionSelectIcons.map(i => i.destroy());
this.optionSelectIcons.splice(0, this.optionSelectIcons.length);