Is there a way in python that if i create a .py file and then will import in a different .py file which has the catch clauses for all the possible exceptions, in such a way
suppose we have a .py file lets say test1
test1.py:
import xyz          
x=5;
print x;
func1()
Now we have test2.py ,which has a try block and except caused for all the possible exceptions. So what I need is that I want the content of test1.py to come inside the try of test2.py .Is there a way either or invoking or importing that I can achieve this?
test2.py
import traceback
import sys
import linecache
# import your file here
try:
    import first
    # invoke your files main method here and run the module
    # it is normal behavior to expect an indentation error if your file and method have not been invoked correctly
except SyntaxError as e:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        #print(sys.exc_info())
        formatted_lines = traceback.format_exc().splitlines()
        #print(formatted_lines)
        temp=formatted_lines[len(formatted_lines) - 3].split(',')
        line_no = str(formatted_lines[len(formatted_lines) - 3]).strip('[]')
        line=line_no.strip(',')
        #print(line[1])
        print " The error method thrown by the stacktrace is  " "'" ,e , "'"
        print " ********************************************* Normal Stacktrace*******************************************************************"
        print(traceback.format_exc())