RE: Error Handling

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

G'day all

Derek Parnell wrote:
> 
> I've written some programs using a flavour of Pick Basic. Many of its
> statements had the syntax of ...
>    <KEYWORD> <PARAMS>
>     ON ERROR <statements>
>     ELSE <statements>
>    END <KEYWORD>
> such as
> 
>    OPEN "thefile.e" FOR OUTPUT
>      ON ERROR
>           PRINT "File Failed to open"
>    END OPEN
> 
> I hated using it but after a while it was occasionally useful. But I
> digress.
> <snip> 
>

I believe sensible error handling is one of Eu's great flaws. However, 
Derek's approach requires lots of programmer-supplied error handlers 
scattered throughout the code. This can get fairly tedious after a 
while. I much prefer David Cuny's appoach of a global onError handler, 
especially if that can be backed up with a bit of help from the Eu 
interpreter. 

The interpreter "knows" when an error has occurred, and even tells you 
about it. Wouldn't it be nice if the interpreter tested for an onError 
handler, then passed the handler a couple of "system" variables like 
$errnum and $errmsg, and gave the programmer the option of handling the 
error? Of course, if the dying program didn't have an onError handler, 
the interpreter could just do what it does now, so there'd be no 
breakage of existing code. And if the error was a real nasty, the 
programmer could always abort(1) anyway.

Scoping multiple onError handlers inside funcions/procedures, include 
files, etc, would be nice, too.

Regards
Tony

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

Search



Quick Links

User menu

Not signed in.

Misc Menu