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?

Because exceptions and writing something to infolog are two separate things.

throw error(“error message”) does two actions in sequence:

  1. error(“error message”) = infolog.add(Exception::Error, “error message”)
  2. throw Exception::Error

Catching the exception has no impact to previously called code, including infolog.add().

I fully understand why you expected it to behave differently, but this is how it works.

Nevertheless nothing prevents you from manipulating infolog after catching the error. Typically you remember the number of lines in infolog before try and remove anything new in catch.