+1

What is raising exceptions used for?

Why do you raise and exception if they are already displayed by a try/except statement?

4/20/2019 10:24:45 PM

commapy

1 Answer

New Answer

+5

You want a program to abort if something bad happens, instead of running on and secretly do damage, because data is corrupted or something. So you can control it, for example by raising an exception when the caller of a function gives bad arguments. Program aborts, you give out an error message, the programmer using your function will know what to do about it. If they foresee it, they can use exception handling and prepare a procedure for that case.