Skip to content

Commit 4e0e270

Browse files
committed
Adding new kind of action which is performed in response to the error(for managed version). The ActivityType.Custom allows to specify custom handler that called at processing BugTrap action
1 parent fc5fc02 commit 4e0e270

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

source/Client/BugTrapNet.h

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ namespace IntelleSoft
4747
ShowUI = BTA_SHOWUI,
4848
SaveReport = BTA_SAVEREPORT,
4949
MailReport = BTA_MAILREPORT,
50-
SendReport = BTA_SENDREPORT
50+
SendReport = BTA_SENDREPORT,
51+
Custom = BTA_CUSTOM
5152
};
5253

5354
[Flags]
@@ -373,6 +374,8 @@ namespace IntelleSoft
373374

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

377+
public delegate void CustomActivityDelegate(Object^ sender, String^ reportFilePath);
378+
376379
public ref class ExceptionHandler
377380
{
378381
private:
@@ -391,6 +394,7 @@ namespace IntelleSoft
391394

392395
static void ValidateIoResult(BOOL bResult);
393396

397+
static event CustomActivityDelegate^ customActivityEvent;
394398
internal:
395399
static property System::Exception^ Exception
396400
{
@@ -418,7 +422,7 @@ namespace IntelleSoft
418422

419423
static void FireBeforeUnhandledExceptionEvent(void);
420424
static void FireAfterUnhandledExceptionEvent(void);
421-
425+
static void FireCustomActivityEvent(String^ reportFilePath);
422426
public:
423427
static const int HttpPort = BUGTRAP_HTTP_PORT;
424428

@@ -434,6 +438,12 @@ namespace IntelleSoft
434438
void remove(UnhandledExceptionDelegate^ value);
435439
}
436440

441+
static event CustomActivityDelegate^ CustomActivity
442+
{
443+
void add(CustomActivityDelegate^ value);
444+
void remove(CustomActivityDelegate^ value);
445+
}
446+
437447
static property String^ AppName
438448
{
439449
String^ get(void);
@@ -596,6 +606,11 @@ namespace IntelleSoft
596606
afterUnhandledExceptionEvent(Sender, Arguments);
597607
}
598608

609+
inline void ExceptionHandler::FireCustomActivityEvent(String^ reportFilePath)
610+
{
611+
customActivityEvent(Sender, reportFilePath);
612+
}
613+
599614
inline void ExceptionHandler::BeforeUnhandledException::add(UnhandledExceptionDelegate^ value)
600615
{
601616
beforeUnhandledExceptionEvent += value;
@@ -616,6 +631,16 @@ namespace IntelleSoft
616631
afterUnhandledExceptionEvent -= value;
617632
}
618633

634+
inline void ExceptionHandler::CustomActivity::add(CustomActivityDelegate^ value)
635+
{
636+
customActivityEvent += value;
637+
}
638+
639+
inline void ExceptionHandler::CustomActivity::remove(CustomActivityDelegate^ value)
640+
{
641+
customActivityEvent -= value;
642+
}
643+
619644
inline String^ ExceptionHandler::AppName::get(void)
620645
{
621646
return gcnew String(BT_GetAppName());

source/Client/BugTrapUI.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include "MemStream.h"
2929
#include "VersionInfoString.h"
3030

31+
#ifdef _MANAGED
32+
#include "NetThunks.h"
33+
#endif
34+
3135
#ifdef _DEBUG
3236
#define new DEBUG_NEW
3337
#endif
@@ -1359,8 +1363,12 @@ static void ExecuteHandlerAction(void)
13591363
}
13601364
break;
13611365
case BTA_CUSTOM:
1362-
if (g_pfnCustomActivityHandler != NULL)
1363-
(*g_pfnCustomActivityHandler)(g_szInternalReportFilePath, g_nCustomActivityHandlerParam);
1366+
#ifdef _MANAGED
1367+
NetThunks::FireCustomActivityEvent(g_szInternalReportFilePath);
1368+
#else
1369+
if (g_pfnCustomActivityHandler != NULL)
1370+
(*g_pfnCustomActivityHandler)(g_szInternalReportFilePath, g_nCustomActivityHandlerParam);
1371+
#endif // _MANAGED
13641372

13651373
break;
13661374
}

source/Client/NetThunks.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,18 @@ namespace NetThunks
504504
}
505505
}
506506

507+
void FireCustomActivityEvent(LPCTSTR pszReportFilePath)
508+
{
509+
try
510+
{
511+
ExceptionHandler::FireCustomActivityEvent(gcnew String(pszReportFilePath));
512+
}
513+
catch (Exception^ exception)
514+
{
515+
Debug::WriteLine(exception);
516+
}
517+
}
518+
507519
void FlushTraceListeners(void)
508520
{
509521
try

source/Client/NetThunks.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ namespace NetThunks
146146

147147
void FireAfterUnhandledExceptionEvent(void);
148148

149+
void FireCustomActivityEvent(LPCTSTR pszReportFilePath);
150+
149151
void FlushTraceListeners(void);
150152

151153
inline gcroot<Thread^> GetCurrentThread(void)

0 commit comments

Comments
 (0)