0
When is exception raise useful?
2 odpowiedzi
+ 2
when we cant understand which exception is occurs...
+ 1
You can and should raise an exception when you think something could go wrong with the execution of the code, example: reading user input, the user might purposely enter incorrect data causing the program to crash, if you have exception for this then instead of the program crashing, an error can be raised and the program will continue. lets say I want to read data from a DB and store the information in a object, now we don't have to worry about users errors, but what if the server is down, that will also crash the program, so exceptions can be raised here as well.