Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
ryanj said...

Here are the possible causes of a fatal crash. Which ones of these could be redesigned to not necessarily be fatal?

Offhand I'd say all of them, perhaps bar "Unknown opcode: %d", as that rather suggests something pretty dire has just happened. There are also lower-level stack and heap corruptions that absolutely deserve to be fatal, since in the first case you probably can't find the exception handling logic and in the second case it will almost certainly fail pretty soon with a strikingly similar error. Unfortunately such things may be rather difficult to distinguish from run-of-the-mill errors, but when you do know it really is that bad, you gotta be brutal, and no-one should pretend it simply does not happen, especially not the documentation. If you're wanting guaranteed 24/7 operation, you should be thinking failover cluster and monitor app anyway.

ryanj said...

Whether or not try/catch is the solution

Ah, that is quite limiting. You could possibly return meaningless made-up values that make debugging ridiculously difficult for a fair number, but I'm not playing that game.


On the usage front, first thing I'd like to see in any documentation is that something like:

try 
   play_video() 
catch e 
   display_at(40,40,"video not found or corrupt") 
end try 

is fine, and really your only option if play_video() is some third party component you would rather not modify with the nasty habit of bringing down your entire app, whereas:

procedure main() 
    try 
       ... 
    catch e 
       -- do absolutely nothing, not even quietly write to a log file 
    end try 
end procedure 

is just plain wrong, and one day will inevitably bite both you and your users on the behind, because you just effectively made everyone completely and utterly blind.

Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu