I want to compile a list of all messages my program could present to a user, specifically all errors (to be able to quality-check the wording).
Let's assume I have my own exception class
class MyException( Exception ):
And I would want to find programmatically all instances where I
raise MyException( "This is a baadly worded message with typo." )
Is there an elegant python way to retrieve:
- the message
- the line number
- the (member) function name that raises the exception?
Ideally, it would even work with cases like
msg = "My really long error message\n"
msg += "Where I explain too much to fit it directly into the raise call"
raise MyException( msg )