broad-exception-raised / W0719#

Message emitted:

Raising too general exception: %s

Description:

Used when an except raises a too general exception.

Problematic code:

def small_apple(apple, length):
    if len(apple) < length:
        raise Exception("Apple is too small!")  # [broad-exception-raised]
    print(f"{apple} is proper size.")

Correct code:

def small_apple(apple, length):
    if len(apple) < length:
        raise ValueError("Apple is too small!")
    print(f"{apple} is proper size.")

Created by the exceptions checker.