Feature request > IDE/Syntax

Error Handling

(1/2) > >>

FutureCow:
Can we please have error checking? You should be able to check the return code on commands like LoadSprite for example to gracefully handle if they fail rather than having your program die unexpectedly.

Moru:
In ancient times there were something called "ON ERROR GOTO" so when something failed, your code would jump to some error handler that you made. You didn't have much to go on except some error code though.

FutureCow:
I'm not suggesting a generic method, I'm suggesting a return code per load/creation statement. Yes, I'm aware that they would have to be individually coded on the back end, and yes, I think the amount of effort is warranted. It doesn't look very professional for your program to crash when it could instead give the user a useful error message.

MrTAToad:
I think I mentioned this sort of thing years ago :)  It would be nice to have...

hardyx:
Or using a new language variable like LASTERR to save the last error in a I/O instruction. Old Turbo Pascal used a variable called IOError when you use a file instruction. You can use or not use, but a non zero value indicates an error has occurred.


--- Code: (glbasic) --- LOADSPRITE "nonexistent.png", 1
 IF LASTERR <> 0
      PRINT "Error loading sprite", 0, 0
      loaded = false
 ELSE
      loaded = true
 ENDIF
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version