Skip to content

Custom handling of Chrome error pages #3852

Open

Description

@digorydoo

In previous versions of CEF, the page stayed blank when an error occurred. I implemented OnLoadError and showed my custom error page by loading a data url into the browser.

This worked fine in CEF 123.0.7+g6a21509, but in 131.2.4+gb7543e4 (and maybe earlier), Chrome's error page is first shown, and then replaced by my custom error page. This looks odd to users. Since my own error page can display more specific details about the context, I want to keep mine. Also, the Chrome error pages do not match the style of our corporate design.

Describe the solution you'd like
One solution is to add a flag to CefBrowserSettings that allows me to suppress all Chrome error pages and get the old behaviour back.

settings.allow_chrome_error_pages = false;

Describe alternatives you've considered
Alternatively (or in addition), I'd like an overridable method somehwere that allows me to return the HTML of the error page for a given error.

CefString CefLoadHandler::OnMakeErrorPage(
   CefRefPtr<CefBrowser> browser,
   CefRefPtr<CefFrame> frame,
   ErrorCode errCode,
   const CefString &errText,
   const CefString &failedUrl,
   const CefString &strChromeErrorPage)
{
    return strChromeErrorPage; // either modify or completely replace it with new HTML
}

Activity

  1. magreenblatt commented on Dec 4, 2024

    @magreenblatt
    Collaborator

    Adding a callback to replace the default HTML is probably the best option here.

  2. magreenblatt commented on Apr 1, 2025

    @magreenblatt
    Collaborator

    Note: Error pages are generated in the renderer process via net_error_helper.cc, so these would need to be renderer process callbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions