Skip to content

Commit

Permalink
Pulling hresult data from elmah.io.hresults
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasArdal committed Nov 23, 2023
1 parent b0eb760 commit c9ec704
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 61 deletions.
1 change: 1 addition & 0 deletions src/ExceptionVisualizer/ExceptionVisualizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<ItemGroup>
<PackageReference Include="Elmah.Io.Client" Version="5.0.66" />
<PackageReference Include="Elmah.Io.HResults" Version="1.0.15" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.8.13-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.8.13-preview-1" />
</ItemGroup>
Expand Down
63 changes: 2 additions & 61 deletions src/ExceptionVisualizer/Models/ExceptionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public string HResultDisplay
{
get
{
return $"0x{HResult.ToString("X8")} ({FacilityToString((HResult & 0x7FFF0000) >> 16)} / {(HResult & 0xFFFF)})";
var hResult = Elmah.Io.HResults.HResult.Parse(HResult);
return $"0x{HResult.ToString("X8")} ({hResult.Facility.Name} / {hResult.Code.Name})";
}
}

Expand Down Expand Up @@ -95,65 +96,5 @@ public Task ExecuteAsync(object? parameter, IClientContext clientContext, Cancel
return Task.CompletedTask;
}
}

private static string FacilityToString(int facility)
{
switch (facility)
{
case 0: return "FACILITY_NULL";
case 1: return "FACILITY_RPC";
case 2: return "FACILITY_DISPATCH";
case 3: return "FACILITY_STORAGE";
case 4: return "FACILITY_ITF";
case 7: return "FACILITY_WIN32";
case 8: return "FACILITY_WINDOWS";
case 9: return "FACILITY_SECURITY";
case 10: return "FACILITY_CONTROL";
case 11: return "FACILITY_CERT";
case 12: return "FACILITY_INTERNET";
case 13: return "FACILITY_MEDIASERVER";
case 14: return "FACILITY_MSMQ";
case 15: return "FACILITY_SETUPAPI";
case 16: return "FACILITY_SCARD";
case 17: return "FACILITY_COMPLUS";
case 18: return "FACILITY_AAF";
case 19: return "FACILITY_URT";
case 20: return "FACILITY_ACS";
case 21: return "FACILITY_DPLAY";
case 22: return "FACILITY_UMI";
case 23: return "FACILITY_SXS";
case 24: return "FACILITY_WINDOWS_CE";
case 25: return "FACILITY_HTTP";
case 26: return "FACILITY_USERMODE_COMMONLOG";
case 31: return "FACILITY_USERMODE_FILTER_MANAGER";
case 32: return "FACILITY_BACKGROUNDCOPY";
case 33: return "FACILITY_CONFIGURATION";
case 34: return "FACILITY_STATE_MANAGEMENT";
case 35: return "FACILITY_METADIRECTORY";
case 36: return "FACILITY_WINDOWSUPDATE";
case 37: return "FACILITY_DIRECTORYSERVICE";
case 38: return "FACILITY_GRAPHICS";
case 39: return "FACILITY_SHELL";
case 40: return "FACILITY_TPM_SERVICES";
case 41: return "FACILITY_TPM_SOFTWARE";
case 48: return "FACILITY_PLA";
case 49: return "FACILITY_FVE";
case 50: return "FACILITY_FWP";
case 51: return "FACILITY_WINRM";
case 52: return "FACILITY_NDIS";
case 53: return "FACILITY_USERMODE_HYPERVISOR";
case 54: return "FACILITY_CMI";
case 55: return "FACILITY_USERMODE_VIRTUALIZATION";
case 56: return "FACILITY_USERMODE_VOLMGR";
case 57: return "FACILITY_BCD";
case 58: return "FACILITY_USERMODE_VHD";
case 60: return "FACILITY_SDIAG";
case 61: return "FACILITY_WEBSERVICES";
case 80: return "FACILITY_WINDOWS_DEFENDER";
case 81: return "FACILITY_OPC";
}

return "" + facility;
}
}
}

0 comments on commit c9ec704

Please sign in to comment.