Sign in

username:

password:



Not a member?

Search rabbit-semi



Search tips

Subscribe to rabbit-semi



Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | Rabbit-Semi | error handler for unexpected error occurences


Advertise Here

This is a group for folks designing and programming embedded systems using the Rabbit Semiconductor C-programmable microcontroller. Rabbit Semi is a spin-off from Z-World who makes a variety of embedded modules and tools. This group is not affiliated with either Rabbit or Z-World, but is a user forum for sharing ideas, asking questions, flaunting knowledge, and other typical user group stuff. The Rabbit is a powerful uC, supported by a full-featured C-compiler.

error handler for unexpected error occurences - avanjilth - Oct 29 9:54:41 2009

Hi all.

Is there a handy function to handle unexpected errors within dynamic c like "try catch" for java? Or could you provide a code for sending an error report when a rabbit BL4S100 cannot communicate to a specific ip address?
Thanks.
Mitchell Tiongson

------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )


Re: error handler for unexpected error occurences - Tom Collins - Oct 29 12:28:00 2009

On Oct 29, 2009, at 1:37 AM, avanjilth wrote:
> Is there a handy function to handle unexpected errors within
> dynamic c like "try catch" for java? Or could you provide a code
> for sending an error report when a rabbit BL4S100 cannot
> communicate to a specific ip address?

You typically just need to check the return value of all functions
that you call. Most will give you an error result if there was a
problem, and then you write whatever code you'd like to handle that
case. It doesn't look pretty, but you can do code like this:

error = someFunction();
if (! error)
{
doStuffHere();
error = anotherFunction();
}
if (! error)
{
doMoreStuff();
error = anotherFunctionThatMightFail();
}

if (error)
{
printf( "exiting with error %d\n", error);
}

return error;
Every function that can possibly fail should be able to return an
error code. Look at the error codes in errno.lib for standard error
codes that your functions can use.

-Tom



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )