Commit 4f32453
amyboard: report full sketch traceback (line numbers) to web editor (#1059)
When a sketch fails to load, run_sketch() reported only
"<ExcType>: <message>" back to the web editor over the 'X' sysex frame —
the full traceback (with file/line numbers) was generated by
sys.print_exception() but only went to the serial console, never the
website. In simulate mode the web already shows the full traceback (it
scrapes it off the JS console), so this gap only affected control mode
on real hardware.
Capture sys.print_exception() into an io.StringIO and report that
instead, via a new _format_exc_for_report() helper. Kept as a single
sysex frame (no chunking): real MicroPython tracebacks are ~150-300
bytes and a single frame reliably carries ~768 raw bytes over Web MIDI
(ZDUMP_STREAM_RAW_CHUNK in amy/src/transfer.c). The helper bounds output
to 700 bytes, keeping the tail (MicroPython prints most-recent-call-last,
so the exception line is last) and falling back to the old one-liner if
capture ever fails. The web display already renders multi-line text, so
no web-side change is needed.
The sketch.loop() runtime-error path is intentionally left serial-only:
it runs every ~60ms and reporting from there would spam sysex frames.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 1ad990b commit 4f32453
1 file changed
Lines changed: 27 additions & 2 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
515 | 540 | | |
516 | 541 | | |
517 | 542 | | |
| |||
570 | 595 | | |
571 | 596 | | |
572 | 597 | | |
573 | | - | |
| 598 | + | |
574 | 599 | | |
575 | 600 | | |
576 | 601 | | |
| |||
588 | 613 | | |
589 | 614 | | |
590 | 615 | | |
591 | | - | |
| 616 | + | |
592 | 617 | | |
593 | 618 | | |
594 | 619 | | |
| |||
0 commit comments