One of the marvelous features of Ada is that Exception control is a basic feature in the language. In contrast, most languages have these features as advanced extras. This makes Ada exceptionally fast an powerful on dealing with "Exceptions".
Simply put, an exception is something that is out of the parameters the program is prepared to deal with.
It can be things like:
Do the last two surprise you?
Ada was designed to be part of Embedded Systems. This means that the computer is part of a larger structure, such as a Tank or a Nuclear Reactor.
This means that most of the time, exceptions are not "Errors", or "user's fault", but real life events that escape the programmer's control and prevision.
This is a concept terrifyingly absent in most programming languages. We have to be thankful that Ada was designed with the military in mind.
This is so much the case that EVERY block (as in begin-end pairs) has an exception handler, making them an inseparable begin-exception-end fundamental structure.
The when clause is to indicate what to do when an exception happens.
If the exception case happens, it will execute the code following the arrow "=>".
If the case is not established (by the general code word others to indicate other exceptions, or the explicit exception case.) it will raise the exception to the process that called it. If this process doesn't handle it, it will go all the way to the operating system, stopping the process and finishing execution in the spot.
One thing you should know upfront: If you don't write exception control the program is not that smaller in size. Error control will have to be compiled either way. This is so in any programming language, but usually is outsourced to the operating systems.
If you write it, and don't use it, the behavior of your program will not be heavier. Thanks to Ada great system of exceptions.
It will be a little heavier if you write it and you use it. So if you use it... let it be what it is for. But probably the error check system was build for something, so using it is always better to not using it.
It turns out the price for security is not that much
NOTE:
An exception is NOT a mistake on writing the code like leaving a semicolon out ( these f🤬ers ";")
Nor is a mistake on implementing the logic of the program, as in receiving different results to what you expected.
These are common errors, either of grammar or logic, and Ada is really good at helping you find either of them. But she is specially insisting on the grammar errors.