Show Rails error page for a morph reload#56
Show Rails error page for a morph reload#56codergeek121 wants to merge 4 commits intohotwired:mainfrom
Conversation
* There's still an error after fixing an error and stimulus controller load twice after fixing an error
There was a problem hiding this comment.
Thanks @codergeek121.
Showing errors when they happen is a bit disruptive, and silently ignoring them was intentional. It's quite common to introduce syntax errors and such as you work on code. I think it's fine to ignore those until you get things working again and, then, the page can update.
If anything, I'd like to keep the same behavior with the replace option here. Maybe we could subscribe to some turbo event and cancel the visit if there is an error? Not sure if that will be possible with regular Turbo handling, though 🤔.
|
Thank you for taking a look. I can see your point about showing the full error page being too disruptive, especially on fast and small iterative changes. I personally always liked the instant feedback of an error screen similar to e.g. the react error overlay and I always missed a similar feature in the typical Rails setup. I'll take a look if I can align the |
I noticed that in contrast to the
:replacereload method,:morphwill not display the Rails error page if an updated page raises an error. It will only print an error to the browser's console.I changed the MorphReloader to morph the complete
<html>document, to handle the different<head>s between the Rails error page and the app's layout. This would theoretically also fix that a change to an app's layout would not get picked up by the:morphmethod currently.While the tests are green, my PR is broken, because after morphing from error page to a fixed version, I get the following browser error:
An import map is added after module script load was triggered.and Stimulus controllers run twice.I decided to open up the PR anyways, to start a discussion about a potential implementation or if someone has an idea how to approach the morph error page. I'll probably take another stab tomorrow and try to use Turbo for the Morph Reloader but I ran out of ideas for today.