Our new function cpg_error is called when an error (regular and database) occurs, displaying the error and it's details.
When a query to the cms_config_custom or cms_users table fails or when a connection to the database fails or is closed, the system wouldn't know what theme to use for the error page. This is why the error pages cannot be theme-based.
We could have handled such pages with just a white page with some text but that's not cool. So we designed cpg_page.php.