Skip to main content

Intentionally Insulting Exceptions for Python

CircleCI

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:

  1. The raised error is a given a randomly-selected insulting name
  2. If no message is provided, the error will use a random insulting message
  3. A special keyword argument rating provides 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

Metadata

Release files for insult-error 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for insult-error 0.3.1
File Size Uploaded
insult_error-0.3.1.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for insult-error 0.3.1
File Interpreter ABI Platform
insult_error-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 kB

Release files / insult_error-0.3.1.tar.gz

Download URL insult_error-0.3.1.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
47bce17c9f16ebaa4c209b44ceac6d857e4a05d58607125dd0bb53e7337f9af5
BLAKE2b-256 checksum
How to use checksums
22017ee67b6fdd5c15e3e45aba3a49c2daa09ca56de06697e7bd546536fac96c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / insult_error-0.3.1-py3-none-any.whl

Download URL insult_error-0.3.1-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f3f3ee70a7cfbb97f5509e80af3ac39d277ac8c5fb50115f3a60a5d170a2e53
BLAKE2b-256 checksum
How to use checksums
03b761b63361f24b0b1758ca3c9ae7d6693fe1d8e2b93f3b8db7e3ddd4e55fc5
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.2.1

1 release file

0.1.2

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page