Suppress HSL Error

Hi, me again (sorry)!

Does anyone know how to swallow/surpress an HSL error?

Say I had some HSL code that was expecting an error and returning false if an error occurred, and true if it didn’t, is there a way for the error to occur but not show up in the tracefile? I thought the errorHandler should prevent the error from showing?

I currently have (stripped down) the following in a function:

        onerror goto __errorHandler;
        // ** Something that may trigger error **
        return (hslTrue);

        __errorHandler: {
            err.Clear();
            return (hslFalse);
        }

Thanks!

Hi Gareth - That is the precise function of the onerror statement. It is basically the HSL version of a try/catch. Any exception that occurs during a grouping of code within an ‘onerror goto id’ block will result in execution to bypass any remaining code within the block and jump to the id. Errors which trigger a jump to the id block will not interrupt run time.

This is also available by default and routinely used in method editor, and is not a feature exclusive to HSL. You can even force your own errors via logic to intentionally skip groupings of code and intentionally enter a handling block. I use this frequently as a form of a ‘goto’ - check the HSLErrLib functions in the example code capture below.

You will find that the autogenerated HSL from these type of user error handling blocks in method editor yields the same onerror statement syntax.

-Nick

2 Likes

Hi Nick,
Yes, it jumps into the error handler fine, but it still shows the error in the trace file. Is there a way to supress that?
Thanks

Unfortunately no, there is not. That is built into VENUS.

-Nick

Ok, thanks!