Home › Forums › kdb+ › Problem with log message when using trap › Re: Problem with log message when using trap
-
The error thrown is passed as the first parameter to the function. https://code.kx.com/q/ref/apply/#trap. To allow parameters, you need to have a function of rank 2 or greater, you can then create a projection of a rank 1 function by eliding the first parameter:
q)logError:{-1"Error: ",x;} q)@[10+;`abc;{logError x,". Couldn't add 10 to ",string y}[;`abc]] Error: type. Couldn't add 10 to abc
You can extend this to allow additional parameters to your error function by creating greater rank functions