How to deal with 500 in the frame?

I have a <turbo-frame> and when I submit form it gets replaced. So far it is great and magical.

But if my server returns 500 (I have an unexpected error) Turbo replaces my frame with empty frame and writes ts to console: Response has no matching <turbo-frame id="some-frame"> element.

Is there any way to render response in this case? I want to show user that my site borked and render generic error message that my server side created.

5 Likes

I have been wondering this same question. @AdamLuczynski Did you find a solution? I would love for others to chime in

I think this regards to the general question: how to intercept a response in a turbo frame? In my case, I wanted to intercept the 401 unauthorized. This is my solution.

1 Like

I was able to catch and process a 500 error using the event.detail.success value of the submit-end event. Here’s a video demonstrating:

You may be interested in following the progress of this MR: