yr.exit
exit(
exit_code: int,
reason: str,
return_value: object,
error_cause: ErrorCause | None = None,
) → NoReturnEnd the current app run immediately.
Nothing after this call runs, including the rest of any app that called
the current one. On success, return_value is checked against the
outermost app's declared return type, as if that app had returned it.
Parameters
exit_code
type: int
Process-style exit code; 0 for success, non-zero
for failure.
reason
type: str
Human-readable summary of why the run ended.
return_value
type: object
Value to return to the caller, or None.
error_cause
type: ErrorCause | None = None
Optional structured cause metadata for failure exits.
See ErrorCause.
Raises
AppExit
Always. The outermost app catches it and ends the run.
Examples
End an app successfully when there is nothing more to do:
import yera as yr
@yr.app
def choose_book() -> str | None:
title = yr.text_input("Which book would you like?")
if not title:
yr.exit(
0,
"No book was selected.",
None,
)
return title