Error handling, temporarily replacing _ERRORMESSAGE

I want to test some functions that are causing errors by executing them in protected mode. From the docs:

Here is my code in HGN “ai_build.lua”:


and the function:

function temperror(e)

Instead of “lalala” in the log, I get the message, “Cannot overwrite function _ERRORMESSAGE”.

I get the same error when supplying nil instead of a function. E.g.


The rest of the script does not break since it is protected.

Has anyone messed with this stuff before?