Intentionally insulting exceptions
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
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size insult_error-0.3.1-py3-none-any.whl (5.3 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size insult_error-0.3.1.tar.gz (4.2 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for insult_error-0.3.1-py3-none-any.whl