aegirhall / console-menu

A simple Python menu system for building terminal user interfaces.
MIT License
365 stars 58 forks source link

How to display errors? #92

Open carniz opened 1 year ago

carniz commented 1 year ago

What's the best way to show errors, in case they should occur?

I've tried to use PromptUtils.println(), but I can't seem to make it work.

Example code:

def add_supplier() -> None:
    try:
        new_supplier = read_supplier_df()
        df = pd.concat([df, new_supplier])
        df.to_csv(SUPPLIERS_FILE_PATH)  # could fail if the directory is not writable
    except Exception as ex:
        PromptUtils(Screen()).println(ex)  # Display the full exception

main_menu.append_item(FunctionItem("Add supplier", add_supplier))