Skip to content

Files

Latest commit

 

History

History
22 lines (14 loc) · 386 Bytes

raising-bad-type.md

File metadata and controls

22 lines (14 loc) · 386 Bytes

Pattern: Use of invalid type when raising exception

Issue: -

Description

A raise statement must raise a valid exception type, otherwise Python raises a TypeError at runtime.

Example of incorrect code:

def bad_case():
    raise 1  # [raising-bad-type]

Example of correct code:

def good_case():
    raise ValidException('error details')