- Electron version: 0.37.5
- Operating system: Windows 10

When calling a window's `webContents.downloadURL(URL)` method if the specified URL returns a 404 the `will-download` event on `webContents.session` does not fire and instead a dialog pops up asking the user to save an html file (the contents of the 404 page).

Is this expected behavior and is there any event I can listen to or some other way to get around this? I'd like to handle the error differently if possible.

Thanks

atom/browser/api/atom_api_session.cc
: devtools_network_emulation_client_id_(base::GenerateGUID()),
      browser_context_(browser_context) {
  
  content::BrowserContext::GetDownloadManager(browser_context)->
      AddObserver(this);
  Init(isolate);
  AttachAsUserData(browser_context);
}
Session::~Session() {
  content::BrowserContext::GetDownloadManager(browser_context())->
      RemoveObserver(this);
}
void Session::OnDownloadCreated(content::DownloadManager* manager,
                                content::DownloadItem* item) {
  auto web_contents = item->GetWebContents();
  if (SavePageHandler::IsSavePageTypes(item->GetMimeType()))
    return;
  v8::Locker locker(isolate());
  v8::HandleScope handle_scope(isolate());
  bool prevent_default = Emit(
      "will-download",
      DownloadItem::Create(isolate(), item),
      api::WebContents::CreateFrom(isolate(), web_contents));
  if (prevent_default) {
    item->Cancel(true);
    item->Remove();
  }
}
void Session::ResolveProxy(const GURL& url, ResolveProxyCallback callback) {