OR_LEAVE MACRO

The OR_LEAVE macro is a convenient macro that allows the application developer to de-emphasize auxiliary error checking code in most cases. It is a postfix macro which implements User::LeaveIfError on an integer return type. This means that there is less focus on the error handling code and makes the code easier to read.

Need for OR_Leave Macro

Motive behind using a OR_LEAVE macro is that it should not return an integer value. It is intended for use as a postfix macro at the end of a statement. If OR_LEAVE was to return an integer value, it would encourage its use in the middle of expressions negating its intended purpose which is to reduce the focus on error checking code.

Defining OR_Leave Macro

The OR_LEAVE macro is defined as a postfix operator as shown below:

       
        
       
       #define OR_LEAVE || ELeave
        inline void operator||(TInt aStatus, TLeave /*aTag*/)
            {
            User::LeaveIfError(aStatus);
            }