bugreport in try ... except block

delphi package - automated exception handling
Post Reply
cefird1
Posts: 15
Joined: Mon Nov 07, 2005 5:12 pm

bugreport in try ... except block

Post by cefird1 »

I recently added a bugreport that is mailed to me to an exception handled in a try ... except block

Code: Select all

  mybugreport := CreateBugReport(etHidden);
  SendBugReport(mybugreport,ScreenShot(true));
My problem is that the bugreport does not include the additional information I include in the unhandled exception bugreports by a MadExceptionHandler.OnException event

Code: Select all

procedure TIHASForm.MadExceptionHandler1Exception(
  const exceptIntf: IMEException; var handled: Boolean);
begin
  // add some additional information to the bug report
  exceptIntf.BeginUpdate;
  exceptIntf.BugReportHeader.Add('Survey ID',ComboPlant.Text+' '+EditSurveyID.Text);
  exceptIntf.BugReportHeader.Add('No Samples',IntToStr(GetNoSamples));
  exceptIntf.EndUpdate;
end;
How can get this information included in the handled exception bugreport?
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

You can use NewException instead of CreateBugReport. (Basically CreateBugReport internally uses NewException.) This way you can add the header information before asking for the fully composed bug report.
cefird1
Posts: 15
Joined: Mon Nov 07, 2005 5:12 pm

Post by cefird1 »

Thanks for the quick response. I changed to the following:

Code: Select all

  myException := NewException;
  handled := false;
  IHASForm.MadExceptionHandler1Exception(myException,handled);
  mybugreport := myException.GetBugReport(true);
  SendBugReport(mybugreport,myException.ScreenShot);
It appears to do what I want. Do I need to dispose of myException? If so, how?
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

It's an interface. Interfaces dispose itself when they're out of scope. If "myException" is a local variable, it will dispose itself when the function is left.
cefird1
Posts: 15
Joined: Mon Nov 07, 2005 5:12 pm

Post by cefird1 »

The bugreport I am getting by email shows the exception message as "The application seems to be frozen". This should not be correct because I have "check for frozen main thread" disabled and the handled exception I am trying to get a report on is a query to an Oracle database.

Other than the exception message, everything appears to be as expected.

I am using madExcept 3.0b and Direct Oracle Access 4.0.7.1
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Change "NewException" to "NewException(etNormal)".
Post Reply