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

Bug fix: Better recovery when a Reflex isn't found. #68

Closed DamnedScholar closed 3 years ago

DamnedScholar commented 3 years ago

If reflex_message() fails to find a Reflex for whatever reason, it throws an exception. The code handling the exception expects the reflex variable to have been set, but in this method that variable only gets set inside the try block, so by definition it doesn't exist if the exception needs to be handled. self.broadcast_error() mandates the Reflex as a positional argument, but has conditional logic inside it that handles a case where the variable is falsey, so passing None in that spot solves the problem. I also added a little more detail to the text of the error message.

Fixes #52

DamnedScholar commented 3 years ago

After I fixed that, I noticed that the following except block had message and msg used inconsistently (msg was never getting assigned), so I changed that to match the first block.