Python catch "unknown" exception

Unable to catch the python exception?

First, use a catch all exception and see what exception it throws. The class and module will hint at where you may import the exception to catch from.

import logging
except Exception as error:
        'unhandled exception (class=%s; module=%s)',
        error.__class__ if hasattr(error, '__class__') else 'unknown',
        error.__module__ if hasattr(error, '__module__') else 'unknown')

keywords: Django, MySQL, except ProgrammingError, django.db.utils.ProgrammingError

Did this help you? Please let me know with a comment. Thank you
Posted .

1 comment (RSS)

  1. anonymous

    Worked. Thanks!

Leave a comment