Monday, March 1, 2010

Global::exceptionTextFallThrough

This method looks really strange since it does nothing! However, this one is still quite useful. Sometimes there is a need to display text of the error that was thrown in the infolog but without preventing further code execution. For this purpose the following code can be written:
    try
    {
        throw error("Error");
    }
    catch
    {
    }

The problem with this code is that compiler will generate a warning regarding empty compound statement (the one after catch). To avoid this warning exceptionTextFallThrough() method should be used.

2 comments: