1

How to print the arguments of all types of exception caught in the below code snippet?

I want to catch all the exceptions and send the message as string to another function(say, "note_this_error"). By message, I mean whatever gets printed on the screen had there not been any exception handling code.

try: 
    :: 
except Exception as e: 
    print e.args 
    note_this_error (exception_message_as_string)

I saw the following on Official Python docs:

When an exception occurs, it may have an associated value, also known as the exception’s argument. The presence and type of the argument depend on the exception type.

I use Python 2.7

gsinha
  • 1,165
  • 2
  • 18
  • 43
  • you mean `e.message` or the type of error also? – Padraic Cunningham Jul 19 '14 at 13:42
  • @PadraicCunningham I wanted something like traceback.format_exc() I referred to the linked question and found that. Thanks anyways for your comment – gsinha Jul 19 '14 at 13:49
  • @jonrsharpe Indeed that question linked by you is what I wanted but was not able to find through google. Thanks for linking that question. If you want, we can close this (my) question. – gsinha Jul 19 '14 at 13:51

0 Answers0