This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Error handling?


Error handling?

Postby mlepage » Aug 23, 2003 @ 5:47pm

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?
User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


My Experience

Postby mlepage » Aug 23, 2003 @ 5:51pm

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.
User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


eVC4 exceptions?

Postby mlepage » Aug 23, 2003 @ 5:54pm

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.
User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


Postby Orpe » Aug 23, 2003 @ 6:40pm

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
User avatar
Orpe
pm Member
 
Posts: 78
Joined: Sep 16, 2001 @ 6:51pm
Location: Stockholm, Sweden


Postby mlepage » Aug 23, 2003 @ 8:59pm

User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


Implementing Exceptions

Postby mlepage » Aug 24, 2003 @ 5:20am

I described my exception-like mechanism in other topic "Implementing Exceptions Using setjmp/longjmp"

User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


Postby Digby » Aug 24, 2003 @ 5:26pm

Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Postby Orpe » Aug 24, 2003 @ 7:15pm

User avatar
Orpe
pm Member
 
Posts: 78
Joined: Sep 16, 2001 @ 6:51pm
Location: Stockholm, Sweden


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum