From 5e565afaa4ded139f44275409d9de6685baa2653 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sun, 5 Jan 2025 02:40:28 +0100 Subject: [PATCH] Added try catch construct to prevent error that was breaking reloadHelper tests --- src/ui/abstact-option-select-ui-handler.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ui/abstact-option-select-ui-handler.ts b/src/ui/abstact-option-select-ui-handler.ts index 19eff282193..fa7a6d14ac0 100644 --- a/src/ui/abstact-option-select-ui-handler.ts +++ b/src/ui/abstact-option-select-ui-handler.ts @@ -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);