Try-catch block don\'t work as expected. In Java, if I wrote something similar and an exception occur in the "Try" code, the program executes the "catch"