I have this try block in my code:
try
try: do_something_that_might_raise_an_exception() except ValueError as err: errmsg = \'My custom error
if you want to custom the error type, a simple thing you can do is to define an error class based on ValueError.