How to reduce redundant code during error checking
<blockquote>
  <p><strong>NOTE:</strong> The restriction is that I cannot use exceptions (the code is eventually compiled with exceptions disabled - not under my control). The project is a real-time 3D graphics application. </p>
</blockquote>

<p>I am using my own error class (I had posted a question regarding that not too long ago) which each class uses. Very simple, all it does it records an error during a function call. The function returns that error and it can also be checked by calling <code>SomeClass-&gt;GetLastError()</code>. If it is <code>NO_ERROR</code> (all enums) then we can proceed, although we can chose to ignore it (for example if a particular object does not load, we can ignore it, put an ugly pink box in its place and flag an error). A function <code>CreateScene()</code> is called when a <code>State</code> is created which then proceeds to call various functions that are responsible for creating the scene. All these functions might potentially return an error. So what I then have is something like this:</p>

<pre><code>if (CreateGrid() != NO_ERROR)
{
  mCore-&gt;Terimate();
  mLog-&gt;Error("\n[FATAL] Initialization Failed, check error log");
  return;
}
if (SomeOtherFunc() != NO_ERROR)
{
  mCore-&gt;Terimate();
  mLog-&gt;Error("\n[FATAL] Initialization Failed, check error log");
  return;
}
</code></pre>

<p>The functions called might have different function signatures, so the arguments can be different although the return type is always an integer. I have quite a few calls like the one above so I wrote a <code>#define</code> for it which takes in the function as the parameter and is exactly the same as the code above. So now, the above code looks like:</p>

<pre><code>CALL_FUNC(CreateGrid());
CALL_FUNC(SomeOtherFunc());
</code></pre>

<p>The define is undefined once I am done with it. Anyway, this is the only idea I could come up with. Even though it has an <em>ugly</em> <code>#define</code> the resulting code is clean. Is there a better technique that I should be using here?</p>

<p>Thanks</p>
