Throw an exception, this is what they exist for.
They allow you to use the code to control the error, passing back lines provides too many opportunities for improper handling.
Consider the case when you return a string or iteration in normal mode, checking the error message can cause problems and cannot constantly intercept them, it is also not very Pythonic.
Gareth latty
source share