Home › Forums › kdb+ › Problem with log message when using trap › Re: Problem with log message when using trap
-
Hi, the trap itself needs to be a function otherwise it will be evaluated regardless of whether the application of your function (hclose) fails or not.
https://code.kx.com/q/ref/apply/#when-e-is-not-a-functionq)logError:{-1"Error: ",x;} q)@[10+;10;logError"Can't add"] Error: Can't add 20 q)@[10+;10;{logError"Can't add"}] 20 q)@[10+;`abc;{logError"Can't add"}] Error: Can't add