errortext-0.1.0
توضیحات
Provide error messages for Python exceptions, even if the original message is empty
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | errortext-0.1.0 |
| نام | errortext |
| نسخه کتابخانه | 0.1.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Thomas Aglassinger |
| ایمیل نویسنده | roskakori@users.sourceforge.net |
| آدرس صفحه اصلی | https://github.com/roskakori/errortext |
| آدرس اینترنتی | https://pypi.org/project/errortext/ |
| مجوز | BSD |
# errortext
`errortext` is a Python package to provide error messages for Python
exceptions, even if the original message is empty.
As example consider the following function that might fail in different ways:
```python
from errortext import error_text
def do_something(action_to_perform):
if action_to_perform == "walk":
print("walking")
elif action_to_perform == "sleep":
raise ValueError("must be tired in order to sleep")
elif action_to_perform == "run":
raise NotImplementedError("run")
else:
assert False
```
One could use the following code to run this function and print possible
error details by using the error message of the exception from
`str(error)`:
```python
try:
do_something(action)
print(f"Success: done with {action}")
except Exception as error:
print(f"Error: cannot {action}: {str(error)}")
```
As you notice, some error will not have any meaningful message:
```
do_something("sleep") -> cannot sleep: must be tired in order to sleep
do_something("run") -> cannot run: run
do_something("xxx") -> cannot xxx:
```
No change the error handler to:
```python
print(f"Error with error_text: cannot {action}: {error_text(error)}")
```
The error messages will at least contain some hint at what went wrong:
```
do_something("sleep") -> cannot sleep: must be tired in order to sleep
do_something("run") -> cannot run: NotImplementedError: run
do_something("xxx") -> cannot xxx: AssertionError
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl errortext-0.1.0:
pip install errortext-0.1.0.whl
نصب پکیج tar.gz errortext-0.1.0:
pip install errortext-0.1.0.tar.gz