title: How do I use stack trace to tell me which Exception I should use for Python's try/except
body: <p>I want to write a Try/Except block that catches the <em>specific</em> error causing this stack trace:</p>
  
  <pre><code>  File "/home/me/anaconda2/envs/deepnn/lib/python2.7/site-packages/tensorflow/python/debug/wrappers/local_cli_wrapper.py", line 292, in _prep_cli_for_run_start
      self._run_cli = ui_factory.get_ui(self._ui_type)
    File "/home/me/anaconda2/envs/deepnn/lib/python2.7/site-packages/tensorflow/python/debug/cli/ui_factory.py", line 61, in get_ui
      return curses_ui.CursesUI(on_ui_exit=on_ui_exit, config=config)
    File "/home/me/anaconda2/envs/deepnn/lib/python2.7/site-packages/tensorflow/python/debug/cli/curses_ui.py", line 289, in __init__
      self._screen_init()
    File "/home/me/anaconda2/envs/deepnn/lib/python2.7/site-packages/tensorflow/python/debug/cli/curses_ui.py", line 404, in _screen_init
      self._screen_color_init()
    File "/home/me/anaconda2/envs/deepnn/lib/python2.7/site-packages/tensorflow/python/debug/cli/curses_ui.py", line 409, in _screen_color_init
      curses.use_default_colors()
  _curses.error: use_default_colors() returned ERR
  </code></pre>
  
  <p>But can't figure out how to determine what the correct Exception  is.</p>
  
  <p>I've written the following try/except to get more info:</p>
  
  <pre><code>        try:
               ... call to procedure that generates error ...
          except Exception,e:
              print("type is:", e.__class__.__name__)
              import sys
              print(sys.exc_info())
  </code></pre>
  
  <p>And the result I've gotten is:</p>
  
  <pre><code>type is: error
  (&lt;class '_curses.error'&gt;, error('use_default_colors() returned ERR',), &lt;traceback object at 0x7fdec55abdd0&gt;)
  &gt; /home/me/Projects/kerasECOC/net_manager.py(164)init_model_architecture()
  </code></pre>
  
  <p>But, when I try </p>
  
  <pre><code>Except error,e:
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code>  File "/home/me/Projects/kerasECOC/net_manager.py", line 157, in init_model_architecture
      except error,e:
  NameError: global name 'error' is not defined
  </code></pre>
  
  <p>So, how can I figure out which <em>specific</em> exception to flag?</p>