I am trying to understand the concept of try and except in Python and I know that this can be used to address the issue in the code with out breaking the flow of the application.
I am working on a application that has a client and a developer side. Therefore, I do not want to show the users what was the exact error but instead a code that they can see and then report and issue with it and I can find the error based on that code. I am not able to figure out how to do this.
I looked into the topic Manually raising an exception in Python.
My program is having multiple functions that are connected together trough their calculations, i.e.
def function_1(_input_):
# do some jobs here get the result then,
result = function_2(result)
return result
def function_2(_input_):
# do some jobs here and get the result then,
result = function_3(result)
return result
...
I want to catch errors that happens during this process with error message and the function that caused the problem. I already implemented something like this:
def function_1(_input_):
try:
# do some jobs here get the result then,
result = function_2(result)
except Exception as e:
print(e)
return result
def function_2(_input_):
try:
# do some jobs here and get the result then,
result = function_3(result)
except Exception as e:
print(e)
return result
...