You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
In almost all Python projects, try statements are used to handle errors. However, they act as :GOTO statements, and I'd like to avoid them in any important project files.
The modern replacement for try statements is to use the Result type in Rust. But since we're in Python, we'd need to use a Result implementation, such as... result.
Motivations
Result forces you to:
handle your errors
cover all potential cases
deal with errors without interrupting control flow
It fixes some issues from try, such as:
jumping between flow paths
not handling errors correctly
having confusing, unmaintainable error handling
In other words, even with very little understanding, programmers become nearly perfect in almost all error handling situations. Migrating to result from try is a worthy cause that will lead to improved error handling and better maintainability.