You need to pass the LINENO() in your on error call. As in:
ON ERROR DO CatchErr WITH ERROR(), MESSAGE(), LINENO(), PROGRAM()
>I am trying to catch errors using
>on error do catcherr where catcherr.prg contains:
>"str(ERROR( ))+MESSAGE( )+str(LINENO( ))+pROGRAM( )"
>
>but the lineno() reports back the lineno of catcherr, not where the error actually happens!