Why Try ... Catch does not crash ?

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Just a curious question if the statement in Try block does raise an error which should usually make application crashes , how does Try Catch avoid it ?
I hope my question was clear :D
 
Another way of explaining the same concept as @KMatle did above, could be to read the following as plain English:
Code: Copy
Try
   one o more statements
Catch
   react to exception
End Try
It will become something like: " try these few statements and if any trappable exception occurs catch it and properly react to it".
 
Code: Copy
Try
   A = 3 + 8
Catch
   MsgBox("Oops! my computer can't calculate")
End Try
 
I wonder if a SIGSEGV (segmentation fault at the native level) would be caught...
 
Actually, debugger helps your app to crash,

In other words, if you put a debugger stop inside a try catch block, it will crash as if it were without it.

It is very helpful because the LOG(lastexception) does not tell you the line.
 
I think my question was not clear enough for you except KMatle :)
I know how to use Try Catch and know that if statements in Try block do contain errors , app will execute statements in catch block.

The thing I did not know is why it does not crash while it tries some problematic statements .
If I got KMatle's point , the crash is just an event that get raised by (VM ?) and if you use (try catch), it executes catch block instead.
 
If I got KMatle's point , the crash is just an event that get raised by (VM ?) and if you use (try catch), it executes catch block instead.
That's true. All caught exceptions are exceptions that are explicitly thrown from the internal code or by the JVM (null pointer exception for example).

Hard crashes that theoretically shouldn't happen but practically do happen from time to time will not be caught. Another type of exceptions that will not be caught are "severe exceptions" like out of memory errors or stack overflow errors.
 
Back
Top