Man kann auch selbst Exceptions ausgeben („werfen“).
>>> raise SyntaxError("Text der Fehlermeldung")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SyntaxError: Text der Fehlermeldung
Beispiel:
try:
raise NameError('Hi There')
except NameError:
print('An exception flew by!')
raise