Proper Exception Handling

RacingDog

Active Member
Licensed User
This is definitely long term as the implementation is non-trivial, but I could do with a proper exception handling mechanism. The Help indicates the problems of using a Goto for any reason. But it is worse than that.

If I write a module intended to be used generically using B4PPC, then if there is an error which cannot be handled by that module but needs handling by the calling software, there is no simple method of doing this. Simply having an public error variable, or an error return parameter, or error return value can put a severe strain on the user code as many places may then have to handle this.

For example, reading/writing .ini files. One may have many keys to read/write and any error in the file will be reported many times over for, not just once. You want one error, one report.

One way of solving this would be if it were possible to see the user's current error label possibly via some sort of access procedure. That is probably too grubby. By far the best is the Ada way, as copied by C++ etc, i.e. raise an exception.

I just happen to have such a module (no one surprised huh?), see attachment. You can see the two places where this is a problem quite easily, Select statements handling a value cError.

Anyway, I shan't hold my breathe on this one, it is obviously a bit fundamental.

For the wider readership.....
The module is simple. It is my take on how to simply read/write ini key strings. I included trivial support for handling full line comments the user may have manually added, as these are allowed in normal ini files. I drew a line at implementing partial line comments. So if anyone else wants to see an alternate view on this subject feel free to look, but you are on your own if you use it (maybe, I'm a softy really!)(it seems to work!?!?!).
 

Attachments

  • INIFiles.bas
    5.9 KB · Views: 295
Top