Significance of certain lines in telegram project

if data[“success”] != 1:
print(“Request not successfull”)
print(“This is the response->”, data)
return -999

is it necessary to write the above lines of code as given as in code explanation part1 of telegram project if we have already written code for exception like:

except Exception as e:
print(“Something went wrong when returning the sensor value”)
return -999

because if there is no success then it would always throw an exception and return -999 or am i wrong and there is a case when success !=1 and exception is also not thrown . if yes please tell me about that particular case , if not then what is the significance of writing the code when data[‘success’]!=1 as it will be covered in exception?

Actually, this has been done for double check.

In the try block, something else too can go wrong and it would return exception. However, if error occurs particularly while fetching data, this block would ensure that we are able to comprehend…

1 Like