Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / Catch runtime errors in DBPro.

Author
Message
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 13th Apr 2006 19:24 Edited at: 10th Aug 2006 21:49
This was originally planned to be part of our soon to be released DBpro plugin named STYX.
However, as this is kind of a hack, I decided to take it out of the plugin and release it separately for free.


What does it do?
It catches most (not all!!!) of the runtime errors that can occur in DarkBasic Pro applications.

How to use it?
Simply enclose an error prone block of code with CATCH and ENDCATCH. To find out if an error occured call GET ERROR() (see the docs).
Code example:


When to use it?
Use it very, very carefully. I recommend to use it before loading media or any other actions when the results are not predictable. If an error occured, save all necessary data, display a sensible error message and quit the app. You may skip the last steps at your own risk.

What about runtime errors in TPCs?
Currently only it only handles the commands that come with DBPro and (of course) the ones that will come with the STYX-Plugin. In the help folder there's a file for TPC developers that describes how to make CATCH/ENDCATCH work with their own plugins.

Unzip it into your DarkBasic Pro folder.

Have fun!

Edit: Tested with DBPro v.1.059 and up.


Play Nice! Play Basic! -- Styx PlugIn- Coming Soon!

Attachments

Login to view attachments
Sergey K
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 14th Apr 2006 23:10 Edited at: 14th Apr 2006 23:17
so like Try/except commands? v. nice dude
your way is to disable the dialogs or something that dbp making when you got runtime error?


[edit]
*just read your second part of your post*
ahh so its not disabling dialogs eh? =]

MyNewSite:http://gogetax.com
Forums(About BLO and more):http://gogetax.com/forum
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 14th Apr 2006 23:32
They are similar to Try/Except... just without Except.
If a catchable error occurs during a CATCH/ENDCATCH block, the DBPro app will NOT popup a message box, and it will NOT terminate but continue to run.

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 14th Apr 2006 23:35
Sound like it will come in very handy. Good work I'm currently fixated with C++ at the moment, but if I use any DBP in the meantime, I'll be sure to d/load this and give it a test drive.

Quote: "Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all."
Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 15th Apr 2006 01:00
Awesome thankyou

Theme park simulator wip

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 4th Aug 2006 20:58 Edited at: 4th Aug 2006 21:11
Just tested it with upgrade 6.2b and it worked.

Since quite a few people have asked me what exactly this plug in does, I'll give you a little example:

Let's say your program wants to load an bitmap given by the user. So the user types (or selects) myImage.bmp.
Now you can check if the file exists and if it does you'll load it. So far, so good. Well, at least as long as "myImage.bmp" is a valid bitmap file. If for some reason DBPro cannot read this file, it'll give you an error message and terminate.

Now with this plugin you can catch those kind of runtime errors, give the user a more meaningful error message and decide yourself if and when the program should quit.




Play Nice! Play Basic! -- Styx PlugIn- Coming Soon!
ThomasFN
20
Years of Service
User Offline
Joined: 26th Aug 2004
Location:
Posted: 8th Aug 2006 23:00
god if this thing actually nums out runtimes i might just put a try catch round the whole program...

well i know i' definelty make use of this plugin thanx

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 9th Aug 2006 07:51
Awesome! This is amazing thanks!

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 9th Aug 2006 11:36
Quote: "god if this thing actually nums out runtimes i might just put a try catch round the whole program..."

I woulddn't do that. Because
1) it doesn't catch all runtime errors (in fact, compiler related stuff won't be catched, like 0 divisions etc.),
2) internal resources might not be freed.

Best thing is to use it for small error prone code blocks.


Quote: "Awesome! This is amazing thanks!"

Thanks.


Play Nice! Play Basic! -- Styx PlugIn- Coming Soon!
ThomasFN
20
Years of Service
User Offline
Joined: 26th Aug 2004
Location:
Posted: 9th Aug 2006 19:30
yes i know i wasnt really gonna do that... just emphasizing how useful this will be in my projects

the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 9th Aug 2006 19:54
Just using it to wrap media loading is pretty useful. Being able to display something useful like the filename is miles better than the current dbpro errors.
It's really hard to use line numbers if there are several versions of your program out there and with the include situation.

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 9th Aug 2006 21:48
Quote: "yes i know i wasnt really gonna do that... just emphasizing how useful this will be in my projects"

Ah, I see. Glad you find it useful.

Quote: "Just using it to wrap media loading is pretty useful. Being able to display something useful like the filename is miles better than the current dbpro errors.
It's really hard to use line numbers if there are several versions of your program out there and with the include situation."

Yes, that's the best use of it. Display a more meaningful message and terminate the program safely.


Play Nice! Play Basic! -- Styx PlugIn- Coming Soon!
Tartopom
20
Years of Service
User Offline
Joined: 27th Jun 2004
Location:
Posted: 9th Aug 2006 23:28
A superb plugin, empty, nice job
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 10th Aug 2006 15:55
OMG this is the best thing ever to happen for DBP in general. Thank you very much Why they did not include this has always baffled me.

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Aug 2006 21:50
Thanks guys. Well it's been here since April...

A little update with (very) slight performance improvements.


Play Nice! Play Basic! -- Styx PlugIn- Coming Soon!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-23 00:27:09
Your offset time is: 2024-11-23 00:27:09