Silently sending bug report on closing app

delphi package - automated exception handling

Silently sending bug report on closing app

Postby stuartclennett » Wed Jan 30, 2013 3:56 pm

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;
stuartclennett
 
Posts: 26
Joined: Thu Dec 20, 2012 10:02 am

Re: Silently sending bug report on closing app

Postby madshi » Wed Jan 30, 2013 4:04 pm

Not sure if this helps but try:

Code: Select all
exc.SendInBackground := false;
madshi
Site Admin
 
Posts: 9962
Joined: Sun Mar 21, 2004 5:25 pm

Re: Silently sending bug report on closing app

Postby stuartclennett » Thu Jan 31, 2013 10:50 am

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
stuartclennett
 
Posts: 26
Joined: Thu Dec 20, 2012 10:02 am

Re: Silently sending bug report on closing app

Postby madshi » Thu Jan 31, 2013 10:58 am

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.
madshi
Site Admin
 
Posts: 9962
Joined: Sun Mar 21, 2004 5:25 pm

Re: Silently sending bug report on closing app

Postby stuartclennett » Thu Jan 31, 2013 11:36 am

Thanks =)
stuartclennett
 
Posts: 26
Joined: Thu Dec 20, 2012 10:02 am

Re: Silently sending bug report on closing app

Postby wpostma » Wed Feb 20, 2013 3:23 pm

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
wpostma
 
Posts: 19
Joined: Fri Oct 12, 2012 4:09 pm

Re: Silently sending bug report on closing app

Postby madshi » Wed Feb 20, 2013 3:48 pm

@Warren, are you talking to me or to Stuart? If you're talking to me, what exactly do you mean? I'm not sure...
madshi
Site Admin
 
Posts: 9962
Joined: Sun Mar 21, 2004 5:25 pm


Return to madExcept

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests