mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00
41 lines
688 B
Python
41 lines
688 B
Python
"""
|
|
Violation:
|
|
|
|
Raising vanilla exception with custom message means it should be customized.
|
|
"""
|
|
|
|
from somewhere import exceptions
|
|
|
|
|
|
def func():
|
|
a = 1
|
|
if a == 1:
|
|
raise Exception("Custom message")
|
|
|
|
b = 1
|
|
if b == 1:
|
|
raise Exception
|
|
|
|
|
|
def ignore():
|
|
try:
|
|
a = 1
|
|
except Exception as ex:
|
|
# This is another violation, but this specific analyzer shouldn't care
|
|
raise ex
|
|
|
|
|
|
def anotherfunc():
|
|
a = 1
|
|
if a == 1:
|
|
raise exceptions.Exception("Another except") # That's fine
|
|
|
|
|
|
def yetanotherfunc():
|
|
a = 1
|
|
if a == 1:
|
|
raise BaseException("Custom message")
|
|
|
|
b = 1
|
|
if b == 1:
|
|
raise BaseException
|