Silently sending bug report on closing app

delphi package - automated exception handling
Post Reply
stuartclennett
Posts: 26
Joined: Thu Dec 20, 2012 10:02 am

Silently sending bug report on closing app

Post by stuartclennett »

Hi Mathias,

Is there a way to check that madExcept.SendBugReport has actually finished sending please? When necessary, I am creating an exception in the FormCloseQuery event handler of the main form, and passing it to the function below.

But if I let the app close naturally then it's very unlikely I'll get the bugreport, & if I do then I get the bugreport email but without the bugreport.txt attachment.

If I set CanClose = false or put in a MessageDlg, or indeed anything that gives madExcept time to work then I reliably get the bug reports.

However, none of the above is particularly elegant - so is there anyway for me to check whether sending has completed before allowing the app to close.

I don't want to show any pop up message boxes to the user, but I am quite happy for them to see progress bars etc whilst the bug report is creating & sending.

Thanks,
Stuart

Code: Select all

function madExceptSilentSendException(E: Exception) : boolean;
var
  exc: IMEException;
  assis: INVAssistant;
  strBugReport : string;
begin
  exc := madExcept.NewException(etNormal, E);

  // Adding some app specific settings 
  Exc.BugReportHeader['From_User'] := CurrentUser.UserName;
  Exc.BugReportHeader['From_Name'] := CurrentUser.Fullname;
  Exc.BugReportHeader['From_Email'] := CurrentUser.Email_Address;
  Exc.BugReportHeader['DB_CONN'] := RemoteConnectionType;  // e.g. MSSQL, MySQL, SQLite
  Exc.BugReportHeader['DB_URL'] := ClientChannel.TargetURL; // e.g. http://localhost:8099/bin

  // ReplicatorLog is TStringList
  if (e is EReplicationFailed) then
    if assigned(ReplicatorLog) then
      Exc.BugReportHeader['REPLICATOR_LOG'] := ReplicatorLog.Text;

  strBugReport := Exc.GetBugReport(True);  // wait for complete bug report

  exc.MailAddr := CurrentUser.email_address;
  exc.MailFrom := CurrentUser.fullname + '<' + CurrentUser.email_address + '> ';
  result := madExcept.SendBugReport(exc.BugReport, nil, 0, Exc) = madTypes.yes;
  if not result then
    madExcept.AutoSaveBugReport(exc.BugReport, Exc);
end;
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: Silently sending bug report on closing app

Post by madshi »

Not sure if this helps but try:

Code: Select all

exc.SendInBackground := false;
stuartclennett
Posts: 26
Joined: Thu Dec 20, 2012 10:02 am

Re: Silently sending bug report on closing app

Post by stuartclennett »

That is exactly what I was looking for, thanks.

One other thing if I may... does madExcept keep a count of bug reports that were unsent but still saved (during that session only)? I was thinking that if a user just hits "continue" on a bug report, I could send these reports silently on exiting also?

Cheers
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: Silently sending bug report on closing app

Post by madshi »

If you told madExcept to automatically save the bug report in case it doesn't get sent then madExcept will all store them to the bug report file (see documentation). This is not per session, though, unless you manually delete that bug report file at the start of your program.
stuartclennett
Posts: 26
Joined: Thu Dec 20, 2012 10:02 am

Re: Silently sending bug report on closing app

Post by stuartclennett »

Thanks =)
wpostma
Posts: 23
Joined: Fri Oct 12, 2012 4:09 pm

Re: Silently sending bug report on closing app

Post by wpostma »

this seems really useful but this is only set up to be used by this one user's code.

Maybe a more general sample would be helpful?

Warren
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: Silently sending bug report on closing app

Post by madshi »

@Warren, are you talking to me or to Stuart? If you're talking to me, what exactly do you mean? I'm not sure...
Post Reply