https://github.com/v-spassky/no-exceptions
🚨 Errors as values for Python.
https://github.com/v-spassky/no-exceptions
error-handling errors exception-handling exceptions fluent fluent-api functional functional-programming
Last synced: 4 months ago
JSON representation
🚨 Errors as values for Python.
- Host: GitHub
- URL: https://github.com/v-spassky/no-exceptions
- Owner: v-spassky
- License: mit
- Created: 2024-10-12T14:00:45.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-22T16:20:49.000Z (about 1 year ago)
- Last Synced: 2025-06-11T07:54:34.275Z (5 months ago)
- Topics: error-handling, errors, exception-handling, exceptions, fluent, fluent-api, functional, functional-programming
- Language: Python
- Homepage: https://pypi.org/project/no-exceptions/
- Size: 69.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# No exceptions
Errors as values for Python. A more functional alternative to `try-except` blocks, offering less indented code and a
chainable API.
- Do you hate exceptions?
- Do you hate the extra indentation they bring?
- Do you hate the convoluted flow of control they seed?
- Do you hate APIs that throw exceptions in not-really-erroneous cases (like `ZeroDivisionError`, `KeyError`,
`IndexError`, `StopIteration`)?
Use this package to switch from this:
```python
def some_func() -> float:
...
try:
return numerator / denominator
except ZeroDivisionError:
return 0.0
```
to this:
```python
from no_exceptions import try_expecting
def some_func() -> float:
...
return try_expecting(lambda: numerator / denominator, ZeroDivisionError).unwrap_or(0.0)
```