Sending reports to Mantis manually

delphi package - automated exception handling

Sending reports to Mantis manually

Postby dcraggs » Wed Jan 03, 2018 12:44 pm

Hi,

We use MadExcept and Mantis for capturing expceptions.

We are wondering if it was possible to use MadExcept to log issues to Mantis where there is no exception.

We have been looking at madExcept.SendBugReport and it works after a fashion, this is what we have tried:

Code: Select all
procedure SendMadExceptBugReport(const aMessage, aBody:string);
var
  lBugReportFilename: string;
  lSettings : IMESettings;
begin
  lSettings := MESettings;
  lSettings.TitleBar := 'Sending to Mantis ';
  lSettings.ExceptMsg := aMessage;
  lBugReportFilename := General.RemoveFileExtension(ExtractFileName(Application.ExeName)) + 'ProblemReport' + FormatDateTime('yymmddhhnnss',now);
  lSettings.BugReportSendAs := lBugReportFilename +  '.txt';
  madExcept.SendBugReport(aBody,nil,0,lSettings);


Nothing set in lSettings is working apart from BugReportSendAs.

Is there another approach?

Thanks

Dave Craggs
dcraggs
 
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Postby madshi » Wed Jan 03, 2018 1:08 pm

You can use the following helper function, exported by madExcept.pas:

Code: Select all
function MantisUpload  (const mantisUrl        : AnsiString;
                              ssl              : boolean;
                              port             : dword;
                        const httpAuthUser     : UnicodeString;
                        const httpAuthPassword : UnicodeString;
                        const mantisAccount    : UnicodeString;
                        const mantisPassword   : UnicodeString;
                        const title            : UnicodeString;
                        const description      : UnicodeString;
                        const project          : UnicodeString;
                        const area             : UnicodeString;
                        const assignTo         : UnicodeString;
                        const version          : UnicodeString;
                        const os               : UnicodeString;
                        const crc              : UnicodeString;
                        const attachments      : IMEAttachments;
                              parentWindow     : HWND           = 0;
                              hidden           : boolean        = false;
                              background       : boolean        = false;
                        const settings         : IMESettings    = nil  ) : boolean;

Hope that helps?
madshi
Site Admin
 
Posts: 9663
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Postby dcraggs » Wed Jan 03, 2018 1:15 pm

Hi,

Yes, that could help. The Mantis parameters are configured in the project MadExcept settings. Can they be retrieved?

Thanks

Dave
dcraggs
 
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Postby dcraggs » Wed Jan 03, 2018 1:29 pm

Further on my original code, it almost works, just the exceptMSG is not being set and not sure how to send errorDetails. Also trying to change to Caption of the send dialog, but not sure how to do that.

I have added an image of the bug report in mantis:
Attachments
2018-01-03_13-24-07.png
2018-01-03_13-24-07.png (63.34 KiB) Viewed 368 times
dcraggs
 
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Postby madshi » Wed Jan 03, 2018 1:52 pm

Those are the "title" and "description" parameters in the MantisUpload call.

And you can get the data from the settings by using e.g. "MESettings().BugTrackerAccount" etc. See here:

http://help.madshi.net/MESettings.htm#I ... kerAccount
madshi
Site Admin
 
Posts: 9663
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Postby dcraggs » Wed Jan 03, 2018 2:12 pm

I will have a go at that, but before I do, is there any way to get the Mantis.SendBugReport working?

The advantage is is would use whatever has been configured in the MadExcept settings, Email, FogBugz, BugZilla or Mantis.

Thanks

Dave
dcraggs
 
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Postby madshi » Wed Jan 03, 2018 3:16 pm

The "title" and "details" are usually filled by the exception details. If you want to fill these manually, the "SendBugReport()" method is not really a good match. You can still make it work, but in order to re-define the "title" and "details" to custom values, you basically need to modify the IMESettings object you pass to SendBugReport(). If you modify the global MESettings() object, that also affects exceptions that might occur at the same time in another thread, so that's not a good approach. I suppose you could misuse the function "NewException(dontCompleteYet = true)" which basically gives you a new IMEException object instance which inherits from IMESettings. The new object copies all values from the global MESettings() object, and then you can change the properties of the new object. This way you're not changing the global settings.

E.g. you can change the "title" by setting SomeExceptionOrSettingsObject.BugTrackerTitle := 'something'.

http://help.madshi.net/MESettings.htm#I ... ackerTitle
madshi
Site Admin
 
Posts: 9663
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Postby dcraggs » Wed Jan 03, 2018 3:38 pm

Hmm, sounds complicated. Maybe something for a future release?

In then meantime, I have the MantisUpload working including attachments.

Question 1 - what is crc?

Question 2 - can I change the send dialog title easily?

2018-01-03_15-36-31.png
2018-01-03_15-36-31.png (4.1 KiB) Viewed 366 times


Thanks

Dave
dcraggs
 
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Postby madshi » Wed Jan 03, 2018 3:41 pm

All the GUI strings can be modified. See the links to the help in my previous comments. CRC? Probably that's a CRC of the crash callback, which is not useful for non-crashes, of course.
madshi
Site Admin
 
Posts: 9663
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Postby dcraggs » Wed Jan 03, 2018 4:23 pm

Found it - it's SendBoxTitle.

if I do lSettings := MESettings

Are changes to lSettings properties Global?

Dave
dcraggs
 
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Postby madshi » Wed Jan 03, 2018 4:48 pm

Yes.
madshi
Site Admin
 
Posts: 9663
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Postby dcraggs » Thu Jan 04, 2018 11:37 am

Is there any way to create a temporary copy? I did try TIMESettings.Create but that's not available.

I could save the old values of anything I change and then restore, but that is messy.
dcraggs
 
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Postby madshi » Thu Jan 04, 2018 11:41 am

I already told you how. See my comment about "NewException(dontCompleteYet)".
madshi
Site Admin
 
Posts: 9663
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Postby dcraggs » Thu Jan 04, 2018 12:08 pm

OK - I'll give it a go, but you did say that was a misuse of the function :-)

Dave
dcraggs
 
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Postby madshi » Thu Jan 04, 2018 12:13 pm

Yes, I did, but it should still work. So far you're the first user wanting to use madExcept's Mantis reporting feature for other things than crash reports, so you're walking where no man has gone before, so to say. Of course my code is optimized for what madExcept was made for. It's not optimized for using part of its functionality for completely different purposes. It's still possible, but you'll have to live with some uglyness when doing that...
madshi
Site Admin
 
Posts: 9663
Joined: Sun Mar 21, 2004 5:25 pm

Next

Return to madExcept

Who is online

Users browsing this forum: No registered users and 2 guests