-1

every time I throw an exception, my program terminates. Is there a way to throw an exception without terminating it? The reason why I'd want to do it is for testing purposes. In my final product, I will simply print error messages, but I have a lot of classes and exceptions help me see where "errors" are. I throw exceptions sometimes when I want to know if a condition was filled, but isn't necessarily program breaking, meaning that the program could go on after throwing the exception.

Meepo
  • 368
  • 4
  • 19

1 Answers1

3

Consider using try catch instead of throws:

try{
     //statements that may cause an exception
}
//Replace exception(type) with the exception you could be throwing
catch (exception(type) e)‏{ //Example for exception(type) is IOException
     //error handling code
     //e.printStackTrace();
}
Cardinal System
  • 2,749
  • 3
  • 21
  • 42