Intentionally insulting exceptions
Project description
Intentionally Insulting Exceptions for Python
This package provides a set of insulting exceptions you can use to make your future self laugh, bother your collaborators, or both.
The core feature is the InsultError exception class, which behaves just like
a normal exception with a few differences:
- The raised error is a given a randomly-selected insulting name
- If no message is provided, the error will use a random insulting message
- A special keyword argument
ratingprovides some control over how offensive you want the error and message to be (1 being tamest and 10 being meanest)
To start the abuse, you can either explicitly raise InsultErrors in your code,
or you can call always_insult_me to convert all unhandled exceptions to insults.
This works by wrapping sys.excepthook such that the error is changed, but your
+stack trace is not.
Please contribute! This package will be much more fun if not limited to the measly initial set of options. Obviously, racist, sexist, or other bullshit jokes are not welcome.
InsultError Example Usage
from insult_error import InsultError
# raise a random insult with a random message (defaults to rating=5)
raise InsultError
# >>> NotThisAgain: Don't believe everything you think.
# raise a random insult with a user-specified message
raise InsultError('This is my message')
# >>> NotThisAgain: This is my message
# raise a random insult with <= 2 rating
raise InsultError(rating=2)
# >>> ForGodsSake: I don’t have the time or the crayons to explain this to you.
# raise a random insult with <= 6 rating
raise InsultError(rating=6)
# >>> FuckYouBuddy: I envy people who have never met you.
# handle InsultError exceptions (just like normal, non-insulting errors)
try:
raise InsultError
except InsultError:
print('Better luck next time!')
# >>> Better luck next time!
always_insult_me Example Usage
from insult_error import always_insult_me, dont_always_insult_me
# turn on ubiquitous insults, uncaught exceptions will be converted to InsultErrors and messages replaced too
always_insult_me()
raise ValueError('a normal message')
# >>>
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# FuckYouBuddy: I don't have the time or the crayons to explain this to you
# turn off insults, things go back to normal
dont_always_insult_me()
raise ValueError('another normal message')
# >>>
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# ValueError: another normal message
# turn insults back on, but this time preserve error messages
always_insult_me(preserve_msg=True)
raise ValueError('a normal message')
# >>>
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# FuckYouBuddy: a normal message
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file insult_error-0.3.1.tar.gz.
File metadata
- Download URL: insult_error-0.3.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47bce17c9f16ebaa4c209b44ceac6d857e4a05d58607125dd0bb53e7337f9af5
|
|
| MD5 |
0830523058c8ce9bd9ce67b9f2ff7fd8
|
|
| BLAKE2b-256 |
22017ee67b6fdd5c15e3e45aba3a49c2daa09ca56de06697e7bd546536fac96c
|
File details
Details for the file insult_error-0.3.1-py3-none-any.whl.
File metadata
- Download URL: insult_error-0.3.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f3f3ee70a7cfbb97f5509e80af3ac39d277ac8c5fb50115f3a60a5d170a2e53
|
|
| MD5 |
47ff472ec6df61e066e8f58dc92cb1ac
|
|
| BLAKE2b-256 |
03b761b63361f24b0b1758ca3c9ae7d6693fe1d8e2b93f3b8db7e3ddd4e55fc5
|