Giter Site home page Giter Site logo

Catching errors about reflex-dom HOT 7 OPEN

reflex-frp avatar reflex-frp commented on August 30, 2024
Catching errors

from reflex-dom.

Comments (7)

nh2 avatar nh2 commented on August 30, 2024 2

catch issues happening during the initial widget build phase, but not anything happening in response to any Event

Ah, right, that'll be it.

Do you have any ideas about how we should improve this?

@ryantrinkle for the beginning it would probably be enough (or at least very very helpful) if I can pass in an exception handler at the mainWidget level, so that I can catch it and log it.

avoid them completely

I'd like to, but when using lots of standard Hackage/base libraries, it's unavoidable that you trip over one that eventually uses a partial function / error inside. I'd like to be able to be notified when that happens in my users' browsers.

from reflex-dom.

ryantrinkle avatar ryantrinkle commented on August 30, 2024 1

@3noch Yes, definitely. My favorite approach, by far, to exceptions has been to avoid them completely. However, that doesn't mean we wouldn't be better off if we had a decent system for dealing with them when they (hopefully occasionally) do crop up!

from reflex-dom.

ryantrinkle avatar ryantrinkle commented on August 30, 2024

Ah, this is quite a complex issue! I would expect Control.Exception.handle to catch issues happening during the initial widget build phase, but not anything happening in response to any Event other than getPostBuild firing. That's because events are processed in a separate thread - see https://github.com/reflex-frp/reflex-dom/blob/develop/src/Reflex/Dom/Internal.hs#L122

Do you have any ideas about how we should improve this?

from reflex-dom.

3noch avatar 3noch commented on August 30, 2024

It seems to me that FRP and exceptions do not mix well. Instead exceptions should be captured in the types.

from reflex-dom.

3noch avatar 3noch commented on August 30, 2024

@ryantrinkle Ah yes I totally agree. In my limited use cases, I've always wrapped my IO code with catchAll or something similar and exposed the exception through performEvent in the types. That way the FRP model can still deal with the exception, but with normal FRP semantics instead of the imperative kind. If there are Reflex-DOM functions that are non-total, it might be best just to expose the exceptions via the types that way?

from reflex-dom.

ryantrinkle avatar ryantrinkle commented on August 30, 2024

@3noch I don't believe there are any reflex-dom functions that are partial in their own right. However, there's always the possibility of a divide-by-zero or something like that cropping up in user code or by accident in reflex-dom.

One important thing to note is that reflex itself does not currently recover from exceptions during event propagation. Now, event propagation doesn't do IO, so it shouldn't be very likely to run into issues, but divide by zero is still possible.

from reflex-dom.

nh2 avatar nh2 commented on August 30, 2024

One important thing to note is that reflex itself does not currently recover from exceptions during event propagation.

@ryantrinkle If the exceptions bubbled up to mainWidget (thus terminating the FRP network), that would be compatible with this, wouldn't it? If I wanted to recover my app, I'd call mainWidget again.

from reflex-dom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.