somed3v3loper Well-Known Member Licensed User Longtime User Jan 6, 2017 #1 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
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
KMatle Expert Licensed User Longtime User Jan 6, 2017 #2 When an app "crashes" just an exception is raised (like an event). This "event" is catched by your program if you like with try... catch... No magic here
When an app "crashes" just an exception is raised (like an event). This "event" is catched by your program if you like with try... catch... No magic here
udg Expert Licensed User Longtime User Jan 6, 2017 #3 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".
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".
Beja Expert Licensed User Longtime User Jan 6, 2017 #4 Code: Copy Try A = 3 + 8 Catch MsgBox("Oops! my computer can't calculate") End Try
wonder Expert Licensed User Longtime User Jan 6, 2017 #5 I wonder if a SIGSEGV (segmentation fault at the native level) would be caught...
EnriqueGonzalez Expert Licensed User Longtime User Jan 7, 2017 #6 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.
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.
somed3v3loper Well-Known Member Licensed User Longtime User Jan 7, 2017 #7 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.
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.
Erel B4X founder Staff member Licensed User Longtime User Jan 8, 2017 #8 somed3v3loper said: 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. Click to expand... 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.
somed3v3loper said: 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. Click to expand... 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.