error checking on Hank story window

This commit is contained in:
2025-11-11 15:32:40 -06:00
parent 14e3e7e31a
commit a7e877eb25

View File

@@ -1146,10 +1146,15 @@
(window.show)))
(function hankStoryWindow [:String file :ConstructorArgs args &opt :Map<String,HankChoiceTagEvent> onChoiceTags]
(let [story (Story.FromFile file)
(whenLet [story (try (Story.FromFile file)
(catch [e] (return (notify "Failed to parse story from $file: $e" ->:Void {}))))
window (SimpleWindow.create args)]
(localFunction :Void showNextFrame []
(let [frame (story.nextFrame)]
(let [frame (try (story.nextFrame)
(catch [e]
(window.hide)
(notify "Hank runtime error: $e" ->:Void {})
(return)))]
(case frame
(Finished
(window.makeTextV2 "Done"
@@ -1167,7 +1172,10 @@
(doFor tag (nth tags idx)
(when (onChoiceTags?.exists tag)
((dictGet onChoiceTags tag) choice)))
(story.choose idx)
(try (story.choose idx)
(catch [e]
(window.hide)
(notify "Hank runtime error: $e" ->:Void {}) ))
(window.clearControls)
(showNextFrame)
}))))