boucekv
boucekv

Reputation: 1230

Why the error message is shown to the user even if error is catched?

How it is possible that even if the exception is catched in following code

static void errorTestJob(Args _args)
{
    try
    {
        throw error("error message");
    }
    catch(Exception::Error)
    {
        info('no problem');
    }
}

the error message 'error message' is still shown to the user?

I expect only info 'no problem' will be shown.

Is there way to transform error message to the info message or do not show error at all?

Upvotes: 0

Views: 121

Answers (1)

alasimpara
alasimpara

Reputation: 195

From the MSDN documentation:

"The 'Global::error()' does directly add a message to the Infolog."

This means that calling the error() function outputs to the Infolog whether the exception is caught or not. If you do not want to output to the Infolog, you should merely:

throw Exception::Error;

See the difference in the following samples on the MSDN website:

Sample 1 not using Global::error

Sample 2 using Global:error

Upvotes: 3

Related Questions