Recently, I was studying about throwing our own exceptions and I thought that maybe we can use if-else
to check for the "suspicious" code and then deal with it in the if
block. In the corresponding else
block, we may proceed as if no exception arises..
I know it may be a bit difficult to use an if
statement to try catching all the exceptions but it is possible. Plus, I guess it will also be better in terms of memory usage as I have heard that try-catch
blocks are very expensive in terms of memory usage.