Sending reports to Mantis manually

delphi package - automated exception handling
dcraggs
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Sending reports to Mantis manually

Post by dcraggs »

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

Re: Sending reports to Mantis manually

Post by madshi »

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?
dcraggs
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Post by dcraggs »

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

Post by dcraggs »

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.1 KiB) Viewed 9080 times
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Post by madshi »

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
dcraggs
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Post by dcraggs »

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

Re: Sending reports to Mantis manually

Post by madshi »

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
dcraggs
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Post by dcraggs »

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.08 KiB) Viewed 9078 times
Thanks

Dave
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Post by madshi »

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.
dcraggs
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Post by dcraggs »

Found it - it's SendBoxTitle.

if I do lSettings := MESettings

Are changes to lSettings properties Global?

Dave
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Post by madshi »

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

Re: Sending reports to Mantis manually

Post by dcraggs »

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

Re: Sending reports to Mantis manually

Post by madshi »

I already told you how. See my comment about "NewException(dontCompleteYet)".
dcraggs
Posts: 9
Joined: Mon Mar 09, 2015 3:06 pm

Re: Sending reports to Mantis manually

Post by dcraggs »

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

Dave
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Sending reports to Mantis manually

Post by madshi »

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...
Post Reply