Theres one thing I dont really understand about try/catch type constructs,
the whole point of them !!!

I can see why there used, to have one generic error handler it the end of a
function to catch all errors, and therefore allow defensive code to be
written in a non-obtrusive manor. However, I think its much simpler to have
a label at the end of the function, and use (gasp) a "goto" statement. Shock
Horror, but isnt this all try and catch effectively does ???

Admittably I dont do this very often, for fear of my collegues looking at my
code, and the abuse which I would recieve. But in things such as a
Open_CommPort type function, where you need to check the return values of
about 8 functions, and handle any errors, "goto error_label" is spot on.
(Ive actually seen a goto somewhere in Palms source code). On a further
note, your compiled code, inevitably ends up as a bunch of "goto" statements
anyway (what else do you think a "JMP" instruction is ???).

goto end:

end:

Cheers Rik.

> -----Original Message-----
> From: Keith Rollin [SMTP:[EMAIL PROTECTED]]
> Sent: 19 April 2001 21:33
> To:   Palm Developer Forum
> Subject:      Re: Try/Catch blocks don't work under POSE?
> 
> >I should have known better especially after writing so much hardware
> >exception handling in VC++.  At the risk of asking another stupid
> >question.....Can you suggest a procedure or method of handling/trapping
> >these type of exceptions from the application?
> 
> Oh, you're going to hate this:
> 
>       int x=5,y=0;
> 
>       if (y != 0)
>       {
>               x /= y;        // force divide by zero
>       }
>       else
>       {
>               MyErrDisplay ("Can't divide by zero!");
>       }
> 
> Or you can just let Poser display the error messages.  But short of 
> installing a DivideByZero hardware exception handler (something not 
> supported by the OS), there's no way to install an 
> application-defined handler.
> -- 
> 
> -- Keith Rollin
> -- Palm OS Emulator engineer
> 
> P.S. Check out the new e-mail address.  [EMAIL PROTECTED] will work 
> for a while, but anyone mailing me needs to update to the new one 
> eventually.
> 
> -- 
> For information on using the Palm Developer Forums, or to unsubscribe,
> please see http://www.palmos.com/dev/tech/support/forums/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to