Skip to content

Commit

Permalink
Adding new kind of action which is performed in response to the error…
Browse files Browse the repository at this point in the history
…(for managed version). The ActivityType.Custom allows to specify custom handler that called at processing BugTrap action
  • Loading branch information
NeoAnomaly committed Mar 4, 2016
1 parent fc5fc02 commit 4e0e270
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
29 changes: 27 additions & 2 deletions source/Client/BugTrapNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace IntelleSoft
ShowUI = BTA_SHOWUI,
SaveReport = BTA_SAVEREPORT,
MailReport = BTA_MAILREPORT,
SendReport = BTA_SENDREPORT
SendReport = BTA_SENDREPORT,
Custom = BTA_CUSTOM
};

[Flags]
Expand Down Expand Up @@ -373,6 +374,8 @@ namespace IntelleSoft

public delegate void UnhandledExceptionDelegate(Object^ sender, UnhandledExceptionEventArgs^ args);

public delegate void CustomActivityDelegate(Object^ sender, String^ reportFilePath);

public ref class ExceptionHandler
{
private:
Expand All @@ -391,6 +394,7 @@ namespace IntelleSoft

static void ValidateIoResult(BOOL bResult);

static event CustomActivityDelegate^ customActivityEvent;
internal:
static property System::Exception^ Exception
{
Expand Down Expand Up @@ -418,7 +422,7 @@ namespace IntelleSoft

static void FireBeforeUnhandledExceptionEvent(void);
static void FireAfterUnhandledExceptionEvent(void);

static void FireCustomActivityEvent(String^ reportFilePath);
public:
static const int HttpPort = BUGTRAP_HTTP_PORT;

Expand All @@ -434,6 +438,12 @@ namespace IntelleSoft
void remove(UnhandledExceptionDelegate^ value);
}

static event CustomActivityDelegate^ CustomActivity
{
void add(CustomActivityDelegate^ value);
void remove(CustomActivityDelegate^ value);
}

static property String^ AppName
{
String^ get(void);
Expand Down Expand Up @@ -596,6 +606,11 @@ namespace IntelleSoft
afterUnhandledExceptionEvent(Sender, Arguments);
}

inline void ExceptionHandler::FireCustomActivityEvent(String^ reportFilePath)
{
customActivityEvent(Sender, reportFilePath);
}

inline void ExceptionHandler::BeforeUnhandledException::add(UnhandledExceptionDelegate^ value)
{
beforeUnhandledExceptionEvent += value;
Expand All @@ -616,6 +631,16 @@ namespace IntelleSoft
afterUnhandledExceptionEvent -= value;
}

inline void ExceptionHandler::CustomActivity::add(CustomActivityDelegate^ value)
{
customActivityEvent += value;
}

inline void ExceptionHandler::CustomActivity::remove(CustomActivityDelegate^ value)
{
customActivityEvent -= value;
}

inline String^ ExceptionHandler::AppName::get(void)
{
return gcnew String(BT_GetAppName());
Expand Down
12 changes: 10 additions & 2 deletions source/Client/BugTrapUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "MemStream.h"
#include "VersionInfoString.h"

#ifdef _MANAGED
#include "NetThunks.h"
#endif

#ifdef _DEBUG
#define new DEBUG_NEW
#endif
Expand Down Expand Up @@ -1359,8 +1363,12 @@ static void ExecuteHandlerAction(void)
}
break;
case BTA_CUSTOM:
if (g_pfnCustomActivityHandler != NULL)
(*g_pfnCustomActivityHandler)(g_szInternalReportFilePath, g_nCustomActivityHandlerParam);
#ifdef _MANAGED
NetThunks::FireCustomActivityEvent(g_szInternalReportFilePath);
#else
if (g_pfnCustomActivityHandler != NULL)
(*g_pfnCustomActivityHandler)(g_szInternalReportFilePath, g_nCustomActivityHandlerParam);
#endif // _MANAGED

break;
}
Expand Down
12 changes: 12 additions & 0 deletions source/Client/NetThunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,18 @@ namespace NetThunks
}
}

void FireCustomActivityEvent(LPCTSTR pszReportFilePath)
{
try
{
ExceptionHandler::FireCustomActivityEvent(gcnew String(pszReportFilePath));
}
catch (Exception^ exception)
{
Debug::WriteLine(exception);
}
}

void FlushTraceListeners(void)
{
try
Expand Down
2 changes: 2 additions & 0 deletions source/Client/NetThunks.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ namespace NetThunks

void FireAfterUnhandledExceptionEvent(void);

void FireCustomActivityEvent(LPCTSTR pszReportFilePath);

void FlushTraceListeners(void);

inline gcroot<Thread^> GetCurrentThread(void)
Expand Down

0 comments on commit 4e0e270

Please sign in to comment.