Skip to content

Unwind before exiting on UI abort - #109

Merged
floitsch merged 1 commit into
mainfrom
cli-unwind-aborts
Aug 1, 2026
Merged

Unwind before exiting on UI abort#109
floitsch merged 1 commit into
mainfrom
cli-unwind-aborts

Conversation

@floitsch

@floitschfloitsch commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Make the default Ui.abort throw a private identity sentinel so Toit unwinds finally clauses.
  • Add Command.run-for-exit-code, which catches only that sentinel with unwinding and returns status 1.
  • Keep Command.run source-compatible by exiting with the returned nonzero status.
  • Route completion timeout failures through the same unwind-safe abort path.
  • Cover successful execution, callback and parser aborts, finalizer execution, and unrelated exception propagation.

This intentionally changes direct catch: ui.abort behavior: callers now see the private abort sentinel. Such catches were already unsafe because the previous implementation exited immediately.

Testing

  • make test — 16/16 passed

Stack created with GitHub Stacks CLIGive Feedback 💬

Comment threadsrc/ui.toit Outdated
# Inheritance
It is safe to override this method with a custom implementation. The
method should always abort. Either with 'exit 1', or with an exception.
method should always abort.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"should never return"

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@floitsch
floitsch merged commit e525ae8 into mainAug 1, 2026
7 checks passed
@floitsch
floitsch deleted the cli-unwind-aborts branch August 1, 2026 20:19
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@floitsch