better error reporting

This commit is contained in:
Jakob 2023-04-01 20:24:23 +02:00
parent 94a4fff52b
commit 6a10abc334
4 changed files with 31 additions and 30 deletions

View file

@ -16,9 +16,9 @@ namespace EnvyUpdate
switch (idType) switch (idType)
{ {
case "psid": case "psid":
return 101; return 127;
case "pfid": case "pfid":
return 845; return 999;
case "osid": case "osid":
return 57; return 57;
case "dtcid": case "dtcid":
@ -36,7 +36,7 @@ namespace EnvyUpdate
public static string GPUname() public static string GPUname()
{ {
return "Nvidia GeForce GTX 1080ti (debug)"; return "Nvidia GeForce RTX 4080 (debug)";
} }
} }
} }

View file

@ -7,7 +7,7 @@ namespace EnvyUpdate
{ {
public static bool isMobile = false; public static bool isMobile = false;
public static readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; public static readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location;
public static readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; public static readonly string exedirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\";
public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
public static readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; public static readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\";
public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

View file

@ -135,8 +135,8 @@ namespace EnvyUpdate
else else
radioGRD.IsChecked = true; radioGRD.IsChecked = true;
if (File.Exists(GlobalVars.exepath + "skip.envy")) if (File.Exists(GlobalVars.exedirectory + "skip.envy"))
skippedVer = File.ReadLines(GlobalVars.exepath + "skip.envy").First(); skippedVer = File.ReadLines(GlobalVars.exedirectory + "skip.envy").First();
// This little bool check is necessary for debug mode on systems without an Nvidia GPU. // This little bool check is necessary for debug mode on systems without an Nvidia GPU.
if (Debug.isDebug) if (Debug.isDebug)
@ -155,19 +155,19 @@ namespace EnvyUpdate
try try
{ {
// disable SD and try with GRD // disable SD and try with GRD
if (File.Exists(GlobalVars.exepath + "sd.envy")) if (File.Exists(GlobalVars.exedirectory + "sd.envy"))
{ {
File.Delete(GlobalVars.exepath + "sd.envy"); File.Delete(GlobalVars.exedirectory + "sd.envy");
} }
gpuURL = Util.GetGpuUrl(); //try again with GRD gpuURL = Util.GetGpuUrl(); //try again with GRD
MessageBox.Show(Properties.Resources.ui_studionotsupported); MessageBox.Show(Properties.Resources.ui_studionotsupported);
radioGRD.IsChecked = true; radioGRD.IsChecked = true;
} }
catch (ArgumentException) catch (ArgumentException e)
{ {
// Now we have a problem. // Now we have a problem.
MessageBox.Show("ERROR: Invalid API response from Nvidia. Please file an issue on GitHub."); MessageBox.Show("ERROR: Invalid API response from Nvidia. Please file an issue on GitHub.\nAttempted API call:\n" + e.Message);
Environment.Exit(10); Environment.Exit(10);
} }
} }
@ -231,8 +231,8 @@ namespace EnvyUpdate
if (skippedVer != onlineDriv) if (skippedVer != onlineDriv)
{ {
skippedVer = null; skippedVer = null;
if (File.Exists(GlobalVars.exepath + "skip.envy")) if (File.Exists(GlobalVars.exedirectory + "skip.envy"))
File.Delete(GlobalVars.exepath + "skip.envy"); File.Delete(GlobalVars.exedirectory + "skip.envy");
buttonSkip.Content = Properties.Resources.ui_skipversion; buttonSkip.Content = Properties.Resources.ui_skipversion;
buttonSkip.IsEnabled = true; buttonSkip.IsEnabled = true;
} }
@ -267,7 +267,7 @@ namespace EnvyUpdate
{ {
File.Delete(GlobalVars.startmenu + "\\EnvyUpdate.lnk"); File.Delete(GlobalVars.startmenu + "\\EnvyUpdate.lnk");
} }
if ((GlobalVars.exepath == GlobalVars.appdata) && File.Exists(GlobalVars.appdata + "EnvyUpdate.exe")) if ((GlobalVars.exedirectory == GlobalVars.appdata) && File.Exists(GlobalVars.appdata + "EnvyUpdate.exe"))
{ {
MessageBox.Show(Properties.Resources.uninstall_legacy_message); MessageBox.Show(Properties.Resources.uninstall_legacy_message);
Util.SelfDelete(); Util.SelfDelete();
@ -291,18 +291,18 @@ namespace EnvyUpdate
private void radioGRD_Checked(object sender, RoutedEventArgs e) private void radioGRD_Checked(object sender, RoutedEventArgs e)
{ {
if (File.Exists(GlobalVars.exepath + "sd.envy")) if (File.Exists(GlobalVars.exedirectory + "sd.envy"))
{ {
File.Delete(GlobalVars.exepath + "sd.envy"); File.Delete(GlobalVars.exedirectory + "sd.envy");
Load(); Load();
} }
} }
private void radioSD_Checked(object sender, RoutedEventArgs e) private void radioSD_Checked(object sender, RoutedEventArgs e)
{ {
if (!File.Exists(GlobalVars.exepath + "sd.envy")) if (!File.Exists(GlobalVars.exedirectory + "sd.envy"))
{ {
File.Create(GlobalVars.exepath + "sd.envy").Close(); File.Create(GlobalVars.exedirectory + "sd.envy").Close();
Load(); Load();
} }
} }
@ -322,7 +322,7 @@ namespace EnvyUpdate
private void buttonSkip_Click(object sender, RoutedEventArgs e) private void buttonSkip_Click(object sender, RoutedEventArgs e)
{ {
skippedVer = onlineDriv; skippedVer = onlineDriv;
File.WriteAllText(GlobalVars.exepath + "skip.envy", onlineDriv); File.WriteAllText(GlobalVars.exedirectory + "skip.envy", onlineDriv);
buttonSkip.IsEnabled = false; buttonSkip.IsEnabled = false;
buttonSkip.Content = Properties.Resources.ui_skipped; buttonSkip.Content = Properties.Resources.ui_skipped;
MessageBox.Show(Properties.Resources.skip_confirm); MessageBox.Show(Properties.Resources.skip_confirm);

View file

@ -384,7 +384,7 @@ namespace EnvyUpdate
*/ */
//TODO: find way to differentiate between driver types //TODO: find way to differentiate between driver types
if (System.IO.File.Exists(GlobalVars.exepath + "sd.envy")) if (System.IO.File.Exists(GlobalVars.exedirectory + "sd.envy"))
return 18; return 18;
else else
return 1; return 1;
@ -414,39 +414,40 @@ namespace EnvyUpdate
dtcid = GetDTCID(); dtcid = GetDTCID();
dtid = GetDTID(); dtid = GetDTID();
} }
string gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString() + "&dtcid=" + dtcid.ToString() + "&dtid=" + dtid.ToString(); // + "&lid=" + langid.ToString(); string gpuUrlBuild = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString() + "&dtcid=" + dtcid.ToString() + "&dtid=" + dtid.ToString();
string gpuUrl;
using (var c = new WebClient()) using (var c = new WebClient())
{ {
gpuURL = c.DownloadString(gpuURL); gpuUrl = c.DownloadString(gpuUrlBuild);
if (gpuURL.Contains("https://") || gpuURL.Contains("http://")) if (gpuUrl.Contains("https://") || gpuUrl.Contains("http://"))
{ {
//absolute url //absolute url
} }
else if (gpuURL.Contains("//")) else if (gpuUrl.Contains("//"))
{ {
//protocol agnostic url //protocol agnostic url
gpuURL = "https:" + gpuURL; gpuUrl = "https:" + gpuUrl;
} }
else if (gpuURL.StartsWith("driverResults.aspx")) else if (gpuUrl.StartsWith("driverResults.aspx"))
{ {
//relative url //relative url
gpuURL = "https://www.nvidia.com/Download/" + gpuURL; gpuUrl = "https://www.nvidia.com/Download/" + gpuUrl;
} }
else if (gpuURL.Contains("No certified downloads were found")) else if (gpuUrl.Contains("No certified downloads were found"))
{ {
//configuration not supported //configuration not supported
throw new ArgumentException(); throw new ArgumentException(gpuUrlBuild);
} }
else else
{ {
//panic. //panic.
MessageBox.Show("ERROR: Invalid API response from Nvidia. Please file an issue on GitHub."); MessageBox.Show("ERROR: Invalid API response from Nvidia - unexpected web response. Please file an issue on GitHub.");
Environment.Exit(10); Environment.Exit(10);
} }
} }
return gpuURL; return gpuUrl;
} }
public static void DownloadFile(string fileURL, string savePath) public static void DownloadFile(string fileURL, string savePath)