sure it works.

but looking at your code above, you use logaction udf after copy and you don't store the error before it.
thus, you get the error given by logaction, not the copy.