!!! mainContent area MUST present on system page template.
It's geenrates functional widget that does all job.
E.g.: trigger errors and configure http headers for 404 error page.
Please use it as area, or create another one nearby for yourself.
You can even hide system one if you really want to break whole system pages functionality.
Or just create dedicated template for error with mainContent hidden, and leave working one for other things like account/search/shop, etc.