Skip to content

Commit

Permalink
Refactor Global exception handling II
Browse files Browse the repository at this point in the history
- The exception information has been extended with useful information.
- If the checkbox remains marked, the details are sent to our log endpoint.
  • Loading branch information
thomas694 committed May 14, 2021
1 parent d6f19a7 commit 2c8f72e
Show file tree
Hide file tree
Showing 15 changed files with 589 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/TumblThree/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

[assembly: ComVisible(false)]
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
[assembly: AssemblyVersion("1.4.1.0")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
75 changes: 75 additions & 0 deletions src/TumblThree/TumblThree.Applications/DataModels/LogException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;

namespace TumblThree.Applications.DataModels
{
[Serializable]
public class LogException
{
public LogException(Exception ex, bool isLongPathSupported,
string winVersion, string winEdition, string winBitness, string winReleaseId, string winVersionNumber,
string tumblThreeVersion, string tumblThreeBitness,
string defaultBrowser, string defaultBrowserVersion,
string winRegionCulture, string winRegionCountry,
string netFrameworkVersion, string netFrameworkBitness,
DateTime timestamp)
{
ExceptionMessage = ex?.Message;
ExceptionType = ex.GetType().FullName;
Callstack = ex.StackTrace;
InnerException = ex.InnerException?.ToString();
IsLongPathSupported = isLongPathSupported;
WinVersion = winVersion;
WinEdition = winEdition;
WinBitness = winBitness;
WinReleaseId = winReleaseId;
WinVersionNumber = winVersionNumber;
TumblThreeVersion = tumblThreeVersion;
TumblThreeBitness = tumblThreeBitness;
DefaultBrowser = defaultBrowser;
DefaultBrowserVersion = defaultBrowserVersion;
WinRegionCulture = winRegionCulture;
WinRegionCountry = winRegionCountry;
NetFrameworkVersion = netFrameworkVersion;
NetFrameworkBitness = netFrameworkBitness;
Timestamp = timestamp;
}

public string ExceptionMessage { get; set; }

public string ExceptionType { get; set; }

public string Callstack { get; set; }

public string InnerException { get; set; }

public bool IsLongPathSupported { get; set; }

public string WinVersion { get; set; }

public string WinEdition { get; set; }

public string WinBitness { get; set; }

public string WinReleaseId { get; set; }

public string WinVersionNumber { get; set; }

public string TumblThreeBitness { get; set; }

public string TumblThreeVersion { get; set; }

public string DefaultBrowser { get; set; }

public string DefaultBrowserVersion { get; set; }

public string WinRegionCulture { get; set; }

public string WinRegionCountry { get; set; }

public string NetFrameworkVersion { get; set; }

public string NetFrameworkBitness { get; set; }

public DateTime Timestamp { get; set; }
}
}
30 changes: 30 additions & 0 deletions src/TumblThree/TumblThree.Applications/Extensions/NativeMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Runtime.InteropServices;
using System.Security;

namespace TumblThree.Applications.Extensions
{
internal static class NativeMethods
{
[SecurityCritical]
[DllImport("ntdll.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern int RtlGetVersion(ref OSVERSIONINFOEX versionInfo);

[StructLayout(LayoutKind.Sequential)]
internal struct OSVERSIONINFOEX
{
// The OSVersionInfoSize field must be set to Marshal.SizeOf(typeof(OSVERSIONINFOEX))
internal int OSVersionInfoSize;
internal int MajorVersion;
internal int MinorVersion;
internal int BuildNumber;
internal int PlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
internal string CSDVersion;
internal ushort ServicePackMajor;
internal ushort ServicePackMinor;
internal short SuiteMask;
internal byte ProductType;
internal byte Reserved;
}
}
}
20 changes: 20 additions & 0 deletions src/TumblThree/TumblThree.Applications/Services/ILogService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Threading.Tasks;

namespace TumblThree.Applications.Services
{
public interface ILogService
{
string TumblThreeVersionString { get; }

string WindowsVersionString { get; }

string DefaultBrowserString { get; }

string RegionSettingsString { get; }

string NetFrameworkVersionString { get; }

Task SendErrorDetails(Exception ex);
}
}
Loading

0 comments on commit 2c8f72e

Please sign in to comment.