Below are two function definition
def function1():
try:
#Code
#Code
#code to read file is here
#code
return smth
except Exception as e:
raise Exception ('smth1smth1') from e
def function2():
try:
#Code
smth=function1()
data= {#some json key value pairs}
data2=request.post(smth123,data)
#code
return smth
except Exception as e:
print('error:%s, error:%s , %(data.key1, data.key2, str(e)))
raise Exception ('smth2smth2') from e
The test case for this is the file is missing here. I am getting the file missing exception as expected but as variable "data" is not assigned I am also getting the variable referenced before assignment error as well. I don't want to see the exception (error) thrown from the second function i.e function 2 and see the exception from the first i.e. function1 if there is any. How can I achieve this