In the first try block, for the first parameter, I am using a string of "1", "2", or "3" to test out the corresponding error messages. However, I would get mixed results. If I use a "1", it should be caught by the addressNotFound block, a "2" would be caught by the AuthenticationError block, and so forth. When I run the program multiple times with the same parameter, the program seems to jump between the catch blocks. Please help me.
look at line int r = rand() % 100; of Client::open, for example.
You will notice that a decision is made about which exception to throw, not based only on the value of address, but also on the value of r, which is a random value.
For example, if r happens to have a value between 20 and 39 inclusive, AuthenticationError will be thrown, regardless of the value of address.
However, if r >= 60, then the value of address would determine which exception is thrown.