I am going to answer your questions in turn, and then add some comments to the end. I am not an authority on exception handling, but I hope my comments are helpful.
"Not the first way to handle exceptions is doing just that ??
My answer is yes, as you describe it, the first method works by throwing and catching an exception in the same method. However, I don't know that try-throw-catch should work when you describe it.
โI read that itโs best to use an exception in one method and catch it in another way, but this is just one (possibly the best) way. Another way is also legal and correct, is that?โ
I agree that it is better to learn the exceptions from the second method, but the first method is finished. Is it correct? well, what is up to you to decide is your code, after all.
For the most part, I agree that it makes no sense to throw an exception, and then immediately catch that exception in the same method. If we do this because the method is especially long / complicated, and handling the error using a different logic will complicate the situation, then I would suggest moving part of this logic to another method and calling this method and catching its exception.
If our code is simpler, then it can be easy to deal with the error using code that does not consist of throwing exceptions.
My comments:
The try-throw-catch mechanism you mentioned may not need to be thrown by the same method. I would need to read a text that you thought was specific, but I would expect this to not be necessary. If an exception is not required for this exception, then your exception handling strategy is a combination of 1) and 2).
In combo, one method will use the try-throw-catch mechanism to catch the exception caused by the called method. It seems to me that 1) and 2) should work together to form your exception handling strategy.
Now, maybe someone will come and give us some wonderful reasons why we might need to eliminate an exception in the same method. I expect there are some, but to me they seem to be exceptions, not the rule.
Cheers ed