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);
}
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.