- 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/atom_download_manager_delegate.cc
base::FilePath default_download_path = browser_context->prefs()->GetFilePath(
      prefs::kDownloadDefaultDirectory);
  CreateDownloadPathCallback download_path_callback =
      base::Bind(&AtomDownloadManagerDelegate::OnDownloadPathGenerated,
                 weak_ptr_factory_.GetWeakPtr(),
                 download->GetId(), callback);
  content::BrowserThread::PostTask(
      content::BrowserThread::FILE, FROM_HERE,
      base::Bind(&AtomDownloadManagerDelegate::CreateDownloadPath,
                 weak_ptr_factory_.GetWeakPtr(),
                 download->GetURL(),
                 download->GetContentDisposition(),
                 download->GetSuggestedFilename(),
                 download->GetMimeType(),
                 default_download_path,
                 download_path_callback));
  return true;
}
bool AtomDownloadManagerDelegate::ShouldOpenDownload(
    content::DownloadItem* download,
    const content::DownloadOpenDelayedCallback& callback) {
  return true;
}
void AtomDownloadManagerDelegate::GetNextId(
    const content::DownloadIdCallback& callback) {
  static uint32_t next_id = content::DownloadItem::kInvalidId + 1;
  callback.Run(next_id++);
}
}