KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Problem with log message when using trap Re: Problem with log message when using trap

  • jason_fealy

    Member
    November 10, 2021 at 12:00 am

    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-function

    q)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