jonathan-s / django-sockpuppet

Build reactive applications with the django tooling you already know and love.
https://github.com/jonathan-s/django-sockpuppet
MIT License
450 stars 22 forks source link

Emit browser console error when a reflex can't be loaded #138

Closed jonathan-s closed 3 years ago

jonathan-s commented 3 years ago

Type of PR (feature, enhancement, bug fix, etc.)

Description

For any usage < 3.8 it won't emit a browser error due the following bug in python, however for python >= 3.8 it will emit an console log error in the browser stating Reflex couldn't be loaded: (start of python error here).

Perhaps you can give this a try @nerdoc if you've got the chance? You could install it through the following command.

pip install https://github.com/jonathan-s/django-sockpuppet/archive/reflex-load-error.zip

Fixes #137

Why should this be added

Clearer errors are better.

Checklist

nerdoc commented 3 years ago

Hmmm. this does not do the trick yet... I have 2 reflexes. one is ok, the other one has an error and can't be loaded. Now here

try:
    if not self.reflexes:
        self.load_reflexes()

self.load_reflexes()won't get triggered, as self.reflexes still contains the correct one... So it's too late in the game.

If I put a (e.g. syntax) error into both reflexes, this Exception is triggered correctly - I still don't see anything in the browser console, but on the backend:

...}', 'serverMessage': {'subject': 'error', 'body': "Reflex couldn't be loaded: name 'lkdsfhj' is not defined"}}}}]}}

I don't know the internals of SP so well that I can see where the reflexes are loaded in the first place - but it seems that here it is too late.