Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪲 Don't crash the "view program" page if the program has a syntax err…
…or (#5985) It used to be that the "view program" page would crash if a program has syntax errors. The reason is that we try to translate programs from the language of the author to the language of the viewer, but that operation may fail due to parse errors, which would cause the page to fail loading. We used to only check for blanks and avoid translating a program because we knew that programs with blanks would fail to parse; but there are many more reasons that would case a parse failure, so instead of trying to predict them I'm now just catching the error. In this PR I want to address a failure case as quickly as possible. There are some open issues/questions that someone else could/should have a look at later: - I have not written a test yet to make sure this doesn't re-occur. - We do translation in 2 steps: first to English, then to the target language. I don't know if that's on purpose or not; I imagine so, it's what the original code was doing and it must be for a reason. - The original code used to always normalize to English first, then translate to the target language. I've changed it to only translate if the source and target languages are different in order to save compute time. I hope that's doesn't break any use cases I'm not aware of. - We have no way to surface the parse error the user. That may be fine because they can try running the program and then seeing the parse error, but just something to note. **How to test** Write a syntactically invalid program and save it. Use the `/hedy/.../view_program` link to view it, and observe that the page loads successfully. Co-Authored-By: Jesús Pelay <[email protected]>
- Loading branch information