M

Python exceptions

Sometimes in Python is not easy to use the correct exception in a try block, this is a way to do it

Usage

        try:
        	<code>
        	</code>
        except Exception as excep:
            type_msg = "An exception of type {0} occurred. Arguments:\n{1!r}"
            exception_msg = type_msg.format(type(excep).__name__, excep.args)
            print exception_msg

        try:
        	<code>
        	</code>
        except Exception as error:
            return {'error': error}