Try/Catch

BlitzMax Forums/BlitzMax Programming/Try/Catch

JoshK(Posted 2007) [#1]
What is the point of using Try/Catch in the file loaders? All this seems to do is mask the source of any error that occurs.


Qube(Posted 2007) [#2]
You use them to stop your program bombing out.

For example your program reads/writes to files and you want to guarantee that it's safe to do so then use Try / Catch. This way if it's not safe to do it your program won't freak and instead you can display a nice "can not do this" info box.


ziggy(Posted 2007) [#3]
Very usefull when reading from internet or removable devices.


dmaz(Posted 2007) [#4]
I would think the point is to just catch the exception so you can do something more constructive with it.


gweedo767(Posted 2007) [#5]
I have a question about try/catch. When I use it in debug mode it seems to work just fine, it catches the exception (trying to load an invaild image) and goes on with life. However, if I build only the GUI App (disable quick build and debug build) it seems to ignore the try/catch block. Is this intended? What can I do in its place?


Dreamora(Posted 2007) [#6]
It does not needfully ignore it.
Perhaps just the exception is not thrown anymore (file io for example when I remember correctly).
As well the thrown exceptions won't cause runtime errors anymore if not catched.


Azathoth(Posted 2007) [#7]
Some exceptions only get thrown in debug mode.


FlameDuck(Posted 2007) [#8]
Some exceptions only get thrown in debug mode.
Namely those thrown by Assert.