Page 1 of 1

Error handling?

PostPosted: Aug 23, 2003 @ 5:47pm
by mlepage
How are people doing error handling in their Pocket PC programs?

There's the traditional style of having each function return an error code, and having each caller check that code for success or failure. I don't mind that, but I do find it can be tedious and make the code a little ugly.

An augment to that style is to have a global place to set additional error info, and check that for more info if an error code was returned. This is like errno in standard C.

Then, there's the non-local jumping and automatic object destruction of standard C++ exceptions. I find exceptions useful, but my understanding is that they are not supported in eVC3, only in eVC4. Are people using exceptions in eVC4?

Microsoft has its own exception-like mechanism in C and C++, which I assume is supported in eVC3. Are people using this? What's it like?

You can find similar exception-like libraries on the web, or roll your own using setjmp/longjmp. Compared to Microsoft's, they'll have pros and cons. What are your experiences?

Another option is to use setjmp/longjmp in a less structured, more adhoc way. I imagine this could get messy, I've never done it.

Another option, going further down that road, is to be like Quake 2 and basically have one error function which does a longjmp to one error handling place. I think this is OK, but it doesn't really leave much options for handling the error, or recovering from it.

Is anyone using signals to handle errors?

So, what are people doing to handle errors in their Pocket PC programs?

My Experience

PostPosted: Aug 23, 2003 @ 5:51pm
by mlepage
I'll chime in with my views. I'm using eVC3 which is the source of some of my limits.

I would prefer to use standard C++ exceptions, as they work relatively nicely and handle auto object destruction (so resources aren't leaked in the event of an error).

Instead, I spent a bit of time yesterday implementing my own exception-like macros using setjmp/longjmp. They work OK, but of course don't do the auto object destruction.

My nascent app hasn't yet stabilized into one error handling scheme, though that's a new priority for me now. Indeed, I might use two schemes, including traditional error return codes, and exception-like mechanisms.

eVC4 exceptions?

PostPosted: Aug 23, 2003 @ 5:54pm
by mlepage
I'd be interested to know what is up-and-coming for standard C++ exception support for Pocket PC development. Last time I checked, I saw eVC4 supported it, but couldn't target Pocket PC 2002, if I understand correctly.

Has this changed now? What about .NET?

Basically, I'm still using eVC3 and unaware of what the current options are for tools, and what each one supports and doesn't support.

Of all the things eVC3 is missing, exceptions is probably the thing I miss most, followed by iostreams.

PostPosted: Aug 23, 2003 @ 6:40pm
by Orpe
I have myself tried various solutions since 1998 when I first had to develop some Pocket PC (or rather Palm-Sized PC) software.

Microsoft exceptions aka SEH (Structured Exception Handling) are not any more useful for what you describe than setjmp/longjmp. Objects on the stack will not be cleaned up in either case.

However, stack clean-up can be added by having all classes that can potentially be constructed on the stack inherit a certain base class. This method was used in . I have used this package sometimes but I find it to be a bit too intrusive to have to add various base classes etc especially if you want to maintain the same code for multiple platforms.

For Windows CE C++ exception handling is not strictly a compiler issue so although the evc4 compilers support C++ exception handling, that cannot be used on Pocket PC 2002 which is based on WCE 3.0. However, for Pocket PC 2003 which is based on WCE 4.20 you do have C++ exceptions, RTTI etc.

So, basically, things will not be great until WCE 3.x support can be dropped entirely and this may be a while into the future because of all non-upgradeable but still fairly modern Pocket PC 2002:s.

/Orpe

PostPosted: Aug 23, 2003 @ 8:59pm
by mlepage

Implementing Exceptions

PostPosted: Aug 24, 2003 @ 5:20am
by mlepage
I described my exception-like mechanism in other topic "Implementing Exceptions Using setjmp/longjmp"


PostPosted: Aug 24, 2003 @ 5:26pm
by Digby

PostPosted: Aug 24, 2003 @ 7:15pm
by Orpe