playground: surface lambda runtime errors instead of swallowing them silently#4926
Merged
Merged
Conversation
…silently A lambda body whose identifier is unresolved (e.g. com.codename1.io.Util referenced without its import) parses fine during initial script eval — the failure only happens when the listener fires. The EDT then catches the resulting EvalError, no Display error handler is registered, and the UI silently stops responding while the preview still draws. Capture a LambdaErrorHandler on each LambdaValue at construction time so event firings minutes later can still report back. The runner pushes a bridge into PlaygroundContext.reportRuntimeError, and CN1Playground appends an inline editor message (deduped per text), refreshes the markers, and flips the top bar to its failed state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
89ea042 to
06aebee
Compare
Contributor
Cloudflare Preview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
com.codename1.io.Utilwithout its import) parses fine on initial eval — the failure happens only when the listener actually fires. CN1's EDT then catches the resultingEvalError, noDisplayerror handler is registered, and the UI silently stops responding while the preview keeps drawing. Users see the symptom in the bug report: "everything glitches" with no error message.LambdaErrorHandleronbsh.cn1.CN1LambdaSupportthat eachLambdaValuecaptures at construction time, so event firings minutes later can still report back through the original host.LambdaValue.invokenow catchesEvalError/RuntimeException, calls the handler, then rethrows so the existing call sites are unchanged.PlaygroundContext.reportRuntimeErrorvia a newRuntimeErrorReporterinterface.CN1Playgroundsupplies a reporter that dedups (a TextField listener firing on every keystroke shouldn't spam the panel), appends an inline editor message, refreshes the markers, and flips the top bar toshowFailed()+previewColumn.setStale(true).Test plan
./mvnw -pl common -am compilepasses — Java sources compile, including the regeneratedGeneratedCN1Access/GeneratedAccess_com_codenameone_playgroundreflective bindings.PlaygroundSmokeHarnesspasses including the newsmokeLambdaRuntimeErrorSurfacesToReportercase: aRunnable r = () -> DefinitelyMissingType.doStuff()script builds the UI cleanly, then invoking the runnable fires the reporter exactly once with a message naming the unresolved symbol.com.codename1.io.*import removed. Initial preview should render as before; on the first keystroke into the field, expect an inline "Runtime error: Class or variable not found: Util" message in the editor and a red/failed top bar instead of a silent dead UI.🤖 Generated with Claude Code