HeinrichApfelmus / threepenny-gui

GUI framework that uses the web browser as a display.
https://heinrichapfelmus.github.io/threepenny-gui/
Other
441 stars 77 forks source link

Log exceptions to stderr before swallowing them #185

Closed pepeiborra closed 7 years ago

pepeiborra commented 7 years ago

This is a significant quality of life improvement for me. However if there is a better way, please let me know.

pepeiborra commented 7 years ago

Do we need to fix the ghc < 7.8 builds ?

HeinrichApfelmus commented 7 years ago

I'm a bit confused by this change, as the EventLoop.hs module is currently responsible for printing exceptions. Which exception is it that was not shown before?

pepeiborra commented 7 years ago

I am not very familiar with the internals of threepenny-gui, so I may not have placed the handler in the optimal place, I didn't notice the existing exception handler in EventLoop.hs.

The specific exception that prompted this change was being thrown at the top level in the UI monad, if I recall correctly, not inside an Event or Behaviour. But I am not 100% sure as this was a few days ago.

I suppose that this change needs more work as we don't want to print an exception more than once though.

pepeiborra commented 7 years ago

Right, after looking at the existing event handler it seems fine, my question is whether stdout is bound to something sensible at runtime. I had to print to stderr instead (Windows here).

pepeiborra commented 7 years ago

Empirically confirmed that the snap log is going to stderr, so it seems sensible to send the exception output to stderr as well. Perhaps snap (or something else) is capturing stdout in Windows ?

HeinrichApfelmus commented 7 years ago

I have changed the code to use the logging functions specified in the configuration options jsLog in commit f239c9e7d62097c7afe1d8fcbbd7aa24b12bc915 . Does this fix the problem?

pepeiborra commented 7 years ago

Yes! This does the trick. I suppose we can close the pull request now, thanks.