Why won't window.location.href work on error pages?
Because, in fact, you are being shown a document with a data: URL for internal error pages, despite the address bar showing the intended address. You can verify that with DevTools by inspecting window.location in the error page.
data: URLs are not scriptable by Chrome extensions: no host permission allows to inject content scripts into them.
Therefore, attempts to programmatically inject a content script that changes window.location.href (or does console.log) will fail due to missing permissions, and match patterns for content scripts in the manifest won't apply.
How can I get around this?
You can use chrome.tabs.update from the background page to navigate away from the error page.
To detect such an error in a background page, probably the best fit is to use chrome.webNavigation API, though using chrome.webRequest API is also possible (careful with filters, and requires broad permissions). Both will provide tabId to do this.