This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Understanding xdc.runtime.Error handling



Hello,

I read your nice manual "How to use the Error module", now I wonder If I understand correctly:

For example, Semaphore_create gets an error block as parameter. So I think that Semaphore_create will call Error_raise itself and the following code is surplus:

g_NotifySemaphore = Semaphore_create (0, &semParams, &eb) ;
if( Error_check( &eb )  )   // all this is not necessary, true?
{
    Error_raise( &eb, Error_E_generic, "Failed to Create the semaphore.",NULL);
}

Or does Semaphore_create only fill the error block with information and I still have to check it?

Can I generally assume that any bios function that gets an error block as parameter behaves like this?

Thank you,

Markus

  • Markus,

    I think you are correct in saying that "all this is not necessary".  Typically a function which takes an Error_block will raise an error if something bad happened.

    Judah

  • For APIs that take an Error_Block, if a problem occurs, they should call the Error_raise function. Two different things can happen when the error occurs within the API:

    1. If you passed in a NULL Error_Block, the program is going to terminate.

    2. If you passed in an initialized Error_Block, the Error_raise does not terminate the program. Instead it is up to the API to "gracefully" return. At this point you can do the Error_check. There are other APIs to decode information about the Error_getSite, Error_getMsg, etc. note: for APIs that return something (e.g. Semaphore_create), if an error occurs, the return value denotes a failure also. For example with Semaphore_create, you can simply check if the returned handle is NULL. This is faster if you don't care why it failed.

    Todd