Print message and exit when exception occurs