For some reason around patch 8.2.0 when calling UIErrorsFrame:Clear() in the same macro indeed doesn’t clear it. You can use a timer to workaround it, but then it would still appear for a split second
/run C_Timer.After(.2, function() UIErrorsFrame:Clear() end)
I’d advise using an addon now to filter only certain error messages if you don’t want to hide the whole thing
https://www.curseforge.com/wow/addons/error-monster