Skip to content

Commit

Permalink
Added more error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
krisdb2009 committed Aug 31, 2023
1 parent 1e2f00b commit 1530425
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 5 additions & 4 deletions SuperGrate/Classes/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static void Verbose(string Text, bool Raw = false)
/// </summary>
/// <param name="Exception">The exception to log.</param>
/// <param name="Text">The text to convey with the exception.</param>
public static void Exception(Exception Exception, string Text)
public static void Exception(Exception Exception, string Text = "")
{
if (Exception.Message.EndsWith("\r\n"))
{
Expand All @@ -128,10 +128,11 @@ public static void Exception(Exception Exception, string Text)
Verbose(Language.Get("Class/Logger/Prefix/Error") + '\r' + Exception.StackTrace);
if(Exception.InnerException != null)
{
Error(Exception.InnerException.Message);
Verbose(Language.Get("Class/Logger/Prefix/Error") + '\r' + Exception.InnerException.StackTrace);
Logger.Exception(Exception.InnerException);
//Error(Exception.InnerException.Message);
//Verbose(Language.Get("Class/Logger/Prefix/Error") + '\r' + Exception.InnerException.StackTrace);
}
Error(Text);
if (Text != "") Error(Text);
}
/// <summary>
/// Updates the UI with the new progress info.
Expand Down
10 changes: 7 additions & 3 deletions SuperGrate/Classes/WMI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ public static void HandleWMIException(Exception e, string Host)
{
if (e.HResult == -2147023174) //RPC server is unavailable.
{
throw new Exception(Language.Get("Class/WMI/Log/Failed/ConnectToViaWMI", Host));
throw new Exception(Language.Get("Class/WMI/Log/Failed/ConnectToViaWMI", Host), e);
}
if (e.HResult == -2147024891) //Access is denied.
{
throw new Exception(Language.Get("Class/WMI/Log/Failed/ConnectToViaWMIAccessDenied", Host));
throw new Exception(Language.Get("Class/WMI/Log/Failed/ConnectToViaWMIAccessDenied", Host), e);
}
throw new Exception(Language.Get("Class/WMI/Log/Failed/QueryWMI", Host));
if (e.HResult == -2147023838) //WMI service is disabled.
{
throw new Exception(Language.Get("Class/WMI/Log/Failed/WMIServiceDisabled", Host), e);
}
throw new Exception(Language.Get("Class/WMI/Log/Failed/QueryWMI", Host), e);
}
}
}
1 change: 1 addition & 0 deletions SuperGrate/Localization/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
<QueryWMI>Failed to query WMI, {0} might have a corrupt WMI installation. Try to run the command "winmgmt.exe /resetrepository" on the target PC to resolve this issue. https://docs.microsoft.com/en-us/windows/win32/wmisdk/winmgmt</QueryWMI>
<ConnectToViaWMI>Failed to connect to {0} via WMI. Make sure the remote PC is online.</ConnectToViaWMI>
<ConnectToViaWMIAccessDenied>Failed to connect to {0} via WMI because access was denied. Make sure your user account has administrative access to the remote PC.</ConnectToViaWMIAccessDenied>
<WMIServiceDisabled>Failed to connect to {0} via WMI because the WMI service failed to start.</WMIServiceDisabled>
</Failed>
</Log>
</WMI>
Expand Down

0 comments on commit 1530425

Please sign in to comment.