Page 1 of 1

Change Exception Message on createbugreport

Posted: Tue May 23, 2017 9:15 am
by wiegerwijnia
Hello,

I am trying to implement a manual bug report function to fogbugz.

Everything seems to be working fine but the except message is always %exceptMsg%

I registered a exceptionhandler and on a normal crash this works fine and the except message is changed, but when I do a manual send bug report it seems to never call the exceptionhandler.

So how can I change the except message when doing a manual create bug report followed by a send bug report.

Re: Change Exception Message on createbugreport

Posted: Tue May 23, 2017 9:50 am
by madshi
Can you show me the exact code you're using?

Re: Change Exception Message on createbugreport

Posted: Wed May 24, 2017 3:15 pm
by wiegerwijnia
Hello,

A rough code snippet when I do a raise Exception the except get's replaced but on the sendbugreport it reads %exceptMsg%

procedure Exceptionhandler(const exceptIntf: IMEException;
var handled: Boolean);
var
sMessage: string;
begin
sMessage := ('Manual Bug Report');
exceptIntf.ExceptMessage := sMessage;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
RegisterExceptionHandler(Exceptionhandler, stDontSync);
end;

Procedure MadExceptSendbugreport(sSender, sMessage: string);
var
CapturedScreenshot: invbitmap;
begin
CapturedScreenshot := screenshot(true);
CreateBugReport(etNormal, nil, nil, 0, 0, 0, nil, false, nil, esmanual,
nil, 0, '');
MadExcept.SendBugReport(sSender + ' - ' + sMessage,
CapturedScreenshot, 0, nil);
end;

procedure TForm1.btnSendCrashReportClick(Sender: TObject);
begin
MadExceptSendbugreport('User', 'Debug Message');
end;

procedure TForm1.btnSimulateCrashClick(Sender: TObject);
begin
raise Exception.Create('Demo "CreateThread".');
end;

Re: Change Exception Message on createbugreport

Posted: Wed May 24, 2017 3:29 pm
by madshi
Hmmmm... Your "MadExceptSendbugreport" function does not have any Exception object it can work with, does it? So there's no proper way to replace the %exceptMsg% string with something useful. What kind of callstack do you want to get from CreateBugReport? Just the current code location? In that case it might make more sense to use "etFrozen" instead of "etNormal".

Re: Change Exception Message on createbugreport

Posted: Wed May 24, 2017 3:51 pm
by wiegerwijnia
Well I kinda misuse it to log a custom message to fogbugz. I have a reportbug button on my application for that.

I used to do this with a email client but it's a hassle with all the company firewalls, and as fogbugz is http service it's always reachable and easy to attach a screenshot.

So I actually would like to send a custom except message, like button play does not respond or something like that, to fogbugz thru mad_except.

i am an old eurekalog user and i could send a custom bug report to fogbugz and attach the local application log to it with the code below.

procedure Eureka_log_send(sSubject, sFeedback, Smessage, sFileName: string);
var
Options: TEurekaModuleOptions;
Files: TstringList;
begin
Options := TEurekaModuleOptions.Create('');
Files := TstringList.Create;
try
Options.Assign(CurrentEurekaLogOptions);
Options.CustomField[sifBugText] := sFeedback;
Options.CustomField[sifBugType] := sSubject;
Options.CustomField[sifBugID] :=
IntToHex(GetCRC32(Options.CustomField[sifBugType] + Options.CustomField
[sifBugText]), 8);
Options.CustomField[sifMessage] := Smessage;
if sFileName <> '' then
if fileexists(sFileName) then
Files.Add(sFileName);
EurekaLogSend(Options, Files);
finally
FreeAndNil(Files);
FreeAndNil(Options);
end;
end

Re: Change Exception Message on createbugreport

Posted: Wed May 24, 2017 3:59 pm
by madshi
You can use this function exported by madExcept.pas, if that helps:

Code: Select all

function FogBugzUpload (const fogBugzUrl       : AnsiString;
                              ssl              : boolean;
                              port             : dword;
                        const httpAuthUser     : UnicodeString;
                        const httpAuthPassword : UnicodeString;
                        const fogBugzAccount   : UnicodeString;
                        const fogBugzPassword  : UnicodeString;
                        const title            : UnicodeString;
                        const description      : UnicodeString;
                        const project          : UnicodeString;
                        const area             : UnicodeString;
                        const assignTo         : UnicodeString;
                        const version          : UnicodeString;
                        const computerName     : UnicodeString;
                        const contactEMail     : UnicodeString;
                        const crc              : UnicodeString;
                        const attachments      : IMEAttachments;
                        const fields           : IMEFields      = nil;
                              parentWindow     : HWND           = 0;
                              hidden           : boolean        = false;
                              background       : boolean        = false;
                        const settings         : IMESettings    = nil  ) : boolean;

Re: Change Exception Message on createbugreport

Posted: Wed May 24, 2017 4:02 pm
by wiegerwijnia
Excellent looks just what I need thank u I will look into this.

Re: Change Exception Message on createbugreport

Posted: Wed May 24, 2017 5:26 pm
by wiegerwijnia
The following code will upload a bug report but fails to attach the attachement probably because of a wrong fieldname ?

Function MadExcept_Upload_Msg_To_Fogbugz(sSender, sMessage, sFilename: string;
blog: Boolean): Boolean;
var
AttachmentToInclude: IMEAttachments;
CustomFields: IMEFields;
begin
try
AttachmentToInclude := NewAttachments;
AttachmentToInclude.Add('c:\test\test.html', 'test', 'test.zip',
'sFileName');
CustomFields := NewFields;
Customfields.Add('test','test');
madexcept.FogBugzUpload('https://url.fogbugz.com', true, 443, '',
'', fbGeneral1, fbGeneral2, 'Manual Bug Report', 'Description', '', '',
'', '', '', mail@mail.nl', '', AttachmentToInclude, CustomFields, 0,
false, false, nil);
Except
log.wl(0, 0, 'MadExcept_Upload_Msg_To_Fogbugz', 'ExceptCalled', blog)
end;
end;

Re: Change Exception Message on createbugreport

Posted: Wed May 24, 2017 5:36 pm
by wiegerwijnia
nvm my bad code works perfectly, only seems test.html was not at that location.

So u can mark this as solved (-:

Thank again for the assistance