If you say this:
> catch (error:Error) {
> if ($debug) Debug.warn(event.type + " " + error);
You turn the error into a string, which means you have no way to get your hands
on the error (say, to inspect it, or to ask it for a stack trace in runtimes
that support that).
Please use the built-in formatting tools if you need to format your warnings or
errors, so that the objects behind them are preserved for inspection.
Something like this would be much more informative.
> catch (error:Error) {
> if ($debug) Debug.warn("loaderEventHandler: %w", error);