It's actually simpler than that.
You don't need the variable
theERR or the local-function
ErrorHandlingThe *error* function is LOCAL to the routune ... so you don't need to be concerned with any global function named the same (the acad default one) that may exist.
I'd do it like this :
(defun Test (/ *error* )
(defun *error* (msg)
...
); end of ErrorHandling
...
MainFunctions Here
...
(princ)
); end of Test
for fun, have a look at the code I posted .. you'll see a statement that MAY cause a divide by zero error.
See if you can write a self contained routine that will trap that (or in fact any) error.
Post the code when you're done.
[added]
BUT, if you wanted to use the methodology you posted, the second sample is correct.
The *error* function alias needs to be declared before it can be used ... so declare it after the handler definition