In my ASP.NET web application, I have defined custom error pages in my web.config file as follows:
I think you'd instead implement/use the Application_Error event in Global.asax, and do your processing/redirects there.
Providing you call Server.ClearError in that handler, I don't think it will use the customErrors config at all.