---
source: crates/ruff/src/rules/tryceratops/mod.rs
---
TRY003.py:8:15: TRY003 Avoid specifying long messages outside the exception class
   |
 8 |     a = 1
 9 |     if a == 1:
10 |         raise CustomException("Long message")
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003
11 |     elif a == 2:
12 |         raise CustomException("Short")  # This is acceptable
   |

TRY003.py:34:15: TRY003 Avoid specifying long messages outside the exception class
   |
34 | def bad(a):
35 |     if a % 2 == 0:
36 |         raise BadArgCantBeEven(f"The argument '{a}' should be even")
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003
   |

TRY003.py:39:15: TRY003 Avoid specifying long messages outside the exception class
   |
39 | def another_bad(a):
40 |     if a % 2 == 0:
41 |         raise BadArgCantBeEven(f"The argument {a} should not be odd.")
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003
   |

TRY003.py:44:15: TRY003 Avoid specifying long messages outside the exception class
   |
44 | def and_another_bad(a):
45 |     if a % 2 == 0:
46 |         raise BadArgCantBeEven("The argument `a` should not be odd.")
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003
   |


