improve sketch error messages in the editor console#4092
Conversation
This reverts commit 278b9c9.
|
Hi @Nixxx19, I have pulled your branch locally & tried to produce some errors by running some sketches. But check out this particular case when I tried to add Error.msg.bug.mp4As shown in the video, when error occurred, a new window opened up that shows the error. a. The window that opens up shows the same error in both slides. One of them can be removed. |
|
hey @aadityasingh9601, thanks for testing this out! so that full-screen red popup is actually webpack's dev-server overlay, not something the pr is rendering. it only runs in dev mode ( that said you helped me catch a real bug behind it. the html line offset wasn't being applied for inline scripts because of a small string mismatch ( just pushed a fix for it. also added a small range guard on the decoration call so it can't blow up on out-of-range lines. pull latest and it should be gone. the in-editor console message and gutter highlight still work normally. |
Hi @Nixxx19, thanks for the clarification about the red popup, now I get it. |
|
hi @Nixxx19! any idea why i see different console errors instead of "Unexpected token"?
|
hey @skyash-dev! firefox only uses the |
| removeErrorDecorations(codemirrorView.current); | ||
|
|
||
| if (consoleErrors.length === 0) return; |
There was a problem hiding this comment.
i think the decoration clearing may be better scoped to the empty-error case:
if (consoleErrors.length === 0) {
removeErrorDecorations(codemirrorView.current);
return;
}readable + more stable
There was a problem hiding this comment.
i thought about scoping it but kept the unconditional clear on purpose. if a user has an error on line 5, fixes it, then introduces a new error on line 10 on the next run, skipping the clear leaves the old gutter on line 5 even though its already fixed. clear-then-add guarantees the gutters always reflect just the latest run, happy to revisit if you can think of a case where the always-clear causes flicker or perf issues
| const firstError = consoleErrors[0]; | ||
| const errorObj = { stack: firstError.data[0].toString() }; |
There was a problem hiding this comment.
using only consoleErrors[0] actually seems reasonable to me from a UX perspective.
reflects an implicit assumption that:
- the first runtime error is usually the most actionable
- one clear navigation target is often better than many competing ones
- stability/readability matters more than exhaustiveness
maybe.
- keep console output/navigation focused on the primary error only
- but surface all resolved runtime errors through error decorations tooltips
that could reduce console noise while still making secondary issues discoverable contextually near the affected lines.
something similar is already done in editors/platforms like openprocessing, where the primary runtime issue is emphasized while additional diagnostics remain attached to the code locations themselves.
There was a problem hiding this comment.
- the decorate-all part is already in the pr,
targetFileId = pairs[0].file.idfor navigation/focus and every error in that file getsaddErrorDecorationso all the lines get a red gutter - where we differ is the console output, the pr surfaces all errors as text instead of hiding secondary ones behind hover tooltips. kept it that way because the editor audience is mostly beginners and hover-only info gets missed easily
- tooltip widgets on decorations would also be new infra, probably better as a follow up, happy to open an issue to track it if you think its worth doing





closes #4088.
opened the issue first because the editor console was surfacing much less info than the browser devtools, and i wanted to check the direction with maintainers before coding. this pr pulls together what was discussed there.
the short version of the problem: jshint was catching parse errors during preprocessing and then throwing them away, so syntax errors either silently disappeared or got replaced by a generic browser message with no file or line. runtime errors went through two different code paths with different output. the console message was a plain string, so the editor decoration had to re parse the string to recover the file and line it needed, and for blob urls it often failed and fell back to showing the raw blob path.
what the pr does:
=in a let/const/var, etc). one friendly block covers all errors on a run with a single mdn reference at the end, not one block per error.test plan, run locally against a clean p5 sketch:
note: the red overlay that shows in the preview iframe during dev is webpack dev server's runtime error panel from react-refresh-webpack-plugin, not something this pr controls. it does not exist in production builds.