Exception Class Filter using SendAssistant

delphi package - automated exception handling
Post Reply
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Exception Class Filter using SendAssistant

Post by FredS »

Hi,

I have this filter setup and what I want to do is show the SendAssistant and allow the user to send an email with a bugreport and an attachment.
However if I setup "Show Assistant.."->SendAssistant all works as expected but no email is sent.

When reverting to the FULL Exception box all works fine.
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception Class Filter using SendAssistant

Post by madshi »

Is that inside of an exception handler? If so, try calling "exceptIntf.SendBugReport()". That should be similar to the user pressing the "send bug report" button.
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: Exception Class Filter using SendAssistant

Post by FredS »

Hi madshi,

My assumption is that when I setup a special Exception and use the Exception Filter I can decide what is executed next.
My next assumption is that when I chose "Show Assistant.."->SendAssistant it actually sends an email..

Essentially what I want is an option to send non critical errors via email. Stuff madExcept does not get triggered for using the same mechanism. So raising EMadSupportRequest is caught in the filter then the SendAssistant assembles all as if a normal error was triggered. These non critical errors are in a log file which is already part of the normal sending mechanism.

But I am open for easier ways to do this :)

thanks

Fred
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception Class Filter using SendAssistant

Post by madshi »

It would help if you could answer my question:

Is that inside of an exception handler?
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: Exception Class Filter using SendAssistant

Post by FredS »

No from a button:

Code: Select all

type EMADSupportError = class(Exception);
procedure TMainForm.vgOptionsSupportRequestEditPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  inherited;
  raise EMADSupportError.Create('Support Request');
end;


procedure TMainForm.MadExceptionHandlerException(const exceptIntf: IMEException; var Handled: Boolean);
begin
  inherited;
      Log.CloseFile; // mad won't attach unless its closed
      exceptIntf.AdditionalAttachments.Add(Log.FileName, 'Info.log', '', 'LOGFILE'); // add an attachment
      Log.Append := True; // Don't overwrite log for new LogPrints
end;
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception Class Filter using SendAssistant

Post by madshi »

In "TMainForm.MadExceptionHandlerException" you could do "exceptIntf.SendBugReport()", as I suggested in my first comment. Or is that not what you want?
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: Exception Class Filter using SendAssistant

Post by FredS »

It is what I want being new one looks for the easiest option.

Here is what I did and it works except it still attaches a screenshot:

Code: Select all

  if exceptIntf.ExceptObject is EMADSupportError then begin
    exceptIntf.CreateScreenShot := False;
    exceptIntf.SendBugReport(Handle);
    Handled := True;
  end;
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception Class Filter using SendAssistant

Post by madshi »

The screenshot might already be created at that point. Try "exceptIntf.ScreenShot := nil" in addition to "exceptIntf.CreateScreenShot := False;".
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: Exception Class Filter using SendAssistant

Post by FredS »

Code: Select all

  // Support Request
  if exceptIntf.ExceptObject is EMADSupportError then begin
    exceptIntf.CreateScreenShot := False;
    exceptIntf.ScreenShot := nil;
    exceptIntf.SendBugReport(Handle);
    Handled := True;
  end;
Works just like Magic..

Thank you

Fred
Post Reply