How to create a macro that throws on verifying HR and also logs?
<p>I have a scenario in the code where the following pattern exist - </p>

<pre><code>if (!function(A))
{
   log("this is the %d error in this file called %s", num, fileName);
   throw AppException(FUNCTION_ERROR);
}
</code></pre>

<p>the issue with this is you need to do this all the time and the code looks really dirty. so I want to define a macro like - </p>

<pre><code>#define VerifyOrThrow(b, retcode, logerror)
        if (b == 0)                                         \
        {                                                   \
            log(logerror,arg1, arg2)  --&gt;this is the issue        \
            throw(AppException(retcode));                   \
        }
</code></pre>

<p>then I can use it like this in a single line</p>

<pre><code>VerifyOrThrow(functionA(), FUNCTION_ERROR,this is the %d error in this file called %s);
</code></pre>

<p>The issue is I am not sure how to define the macro for the variable length argument for the log string.</p>

<p>Any ideas?</p>
