Skip to content

playground: surface lambda runtime errors instead of swallowing them silently#4926

Merged
shai-almog merged 1 commit into
masterfrom
playground-surface-lambda-runtime-errors
May 12, 2026
Merged

playground: surface lambda runtime errors instead of swallowing them silently#4926
shai-almog merged 1 commit into
masterfrom
playground-surface-lambda-runtime-errors

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • A playground lambda whose body references an unresolved identifier (e.g. com.codename1.io.Util without its import) parses fine on initial eval — the failure happens only when the listener actually fires. CN1's EDT then catches the resulting EvalError, no Display error 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.
  • Add a LambdaErrorHandler on bsh.cn1.CN1LambdaSupport that each LambdaValue captures at construction time, so event firings minutes later can still report back through the original host. LambdaValue.invoke now catches EvalError/RuntimeException, calls the handler, then rethrows so the existing call sites are unchanged.
  • Wire the handler into PlaygroundContext.reportRuntimeError via a new RuntimeErrorReporter interface. CN1Playground supplies 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 to showFailed() + previewColumn.setStale(true).

Test plan

  • ./mvnw -pl common -am compile passes — Java sources compile, including the regenerated GeneratedCN1Access/GeneratedAccess_com_codenameone_playground reflective bindings.
  • PlaygroundSmokeHarness passes including the new smokeLambdaRuntimeErrorSurfacesToReporter case: a Runnable r = () -> DefinitelyMissingType.doStuff() script builds the UI cleanly, then invoking the runnable fires the reporter exactly once with a message naming the unresolved symbol.
  • Manual repro from the bug report: open the playground, paste the encoder snippet with 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

…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>
@shai-almog shai-almog force-pushed the playground-surface-lambda-runtime-errors branch from 89ea042 to 06aebee Compare May 12, 2026 09:24
@github-actions
Copy link
Copy Markdown
Contributor

Cloudflare Preview

@shai-almog shai-almog merged commit 0948012 into master May 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant