robbielyman / seamstress

seamstress is an art engine
GNU General Public License v3.0
123 stars 12 forks source link

fix: print errors in user script pre-`init` #25

Closed andr-ew closed 1 year ago

andr-ew commented 1 year ago

I noticed that pcall appeared to be capturing any (user-caused) errors that occurred in the main body of script.lua (or any files called at the top w/ dofile), rather than printing them in the REPL, which caused some momentary confusion for me.

since the nature of that check & error messages appeared to be more about checking for the existence of the file, regardless of error-free-ness, I tried just dogfooding off of util.exists and using a non-protected require only if the file exists.

not totally sure if this was a bug or intended behavior, but regardless, this new behavior matches my personal expectations better, at least :)

robbielyman commented 1 year ago

Thank you very much! I tweaked it to support keeping script_file in ~/seamstress and took the opportunity to clean up how the Zig function do_call will react to the errors that are emitted, in anticipation of switching from printing to logging in #24. Very much appreciate your easy fix :)