- 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
uint32_t download_id,
    const content::DownloadTargetCallback& callback,
    const base::FilePath& default_path) {
  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
  auto item = download_manager_->GetDownload(download_id);
  if (!item)
    return;
  NativeWindow* window = nullptr;
  auto relay = NativeWindowRelay::FromWebContents(item->GetWebContents());
  if (relay)
    window = relay->window.get();
  base::FilePath path;
  if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path,
                                  file_dialog::Filters(), &path)) {
    
    AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
        download_manager_->GetBrowserContext());
    browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
                                          path.DirName());
  }
  
  
  
  callback.Run(path,
               content::DownloadItem::TARGET_DISPOSITION_PROMPT,
               content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path);
}
void AtomDownloadManagerDelegate::Shutdown() {