madIWSupport not catching exception

delphi package - automated exception handling
Post Reply
bmoelk
Posts: 4
Joined: Mon Jun 21, 2004 5:15 pm
Contact:

madIWSupport not catching exception

Post by bmoelk »

When we upgraded madExcept, to a version that has madIWSupport, our exceptions do not seem to be caught.

When I comment out:

PatchJmp(@TIWServerControllerBase.DoException, @TIWServerControllerBaseDoExceptionCallback);

everything works as expected (we have CreateBugReport calls in the IWServerControllerBaseException). But this requires an edit to madIWSupport.pas.

It would be nice to be able to turn off madIWSupport in intraweb projects. There doesn't seem to be a way to do this. Am I missing something?

using IW 7.1.12 madExcept 2.7c

Thanks!
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Hmmmm... I think you're slightly misunderstanding madExcept's new IW support. In the old version madExcept simply didn't work for IW projects by default. You had to register your own exception handler in IW in order to get access to the exceptions.

The new version changes all that. But you didn't really notice it because your project is still configured for the old version. Please do this:

(1) Enable the option "show exception box".
(2) Call RegisterExceptionHandler to get notified about exceptions (just like you would do in a normal project).
(3) Move the code of your custom IW exception handler to the madExcept style exception handler (which you registered in step (2)).

Does that help? Of course you need to have that "PatchJmp" in if the steps above are supposed to work.
bmoelk
Posts: 4
Joined: Mon Jun 21, 2004 5:15 pm
Contact:

Post by bmoelk »

madshi wrote:Hmmmm... I think you're slightly misunderstanding madExcept's new IW support.
Indeed. Ok, I've hooked it in, but I don't like it. :?

The problem is this:

1) we want to display a simple exception message to the end-user; they won't understand the bug report anyway and it gives too much information for a web app for hackers etc.
2) we want to log the full bug report in the event log. In order to do this and know what user caused the bug report we need access to TIWApplication to get the UserSession information. TExceptEvent doesn't provide this information.

What I would like to have is a way to unhook madIWSupport from intraweb projects but still have the capability of using madExcept "manually". Also, madIWSupport only works in AppMode, so there should be a way to do this to support PageMode.

Regards
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

You can remove the "show bug report" button, then the user can't see it. Also you can customize the text that madExcept shows to the end user.

But if you really don't want to use madIWSupport, then I think you can disable it by using this "trick":

(1) Add this line to your project file (e.g. above the uses clause):

// dontTouchUses

(2) Remove madIWSupport from the uses clause.
(3) Recompile.

As a result madExcept will not change the uses clause of the project file, anymore. So madIWSupport will not be added again.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

P.S: I'm no expert in Internet programming at all. Why does madIWSupport not work in Page mode?

:(
bmoelk
Posts: 4
Joined: Mon Jun 21, 2004 5:15 pm
Contact:

Post by bmoelk »

madshi wrote:You can remove the "show bug report" button, then the user can't see it. Also you can customize the text that madExcept shows to the end user.
I'll have to check tomorrow, but this may still push the report to the client. This is still something we don't want to do.

I'll try this:

// dontTouchUses

Will Delphi like it as you add/remove files to the project?

Thanks for your help!
bmoelk
Posts: 4
Joined: Mon Jun 21, 2004 5:15 pm
Contact:

Post by bmoelk »

madshi wrote:P.S: I'm no expert in Internet programming at all. Why does madIWSupport not work in Page mode?
madIWSupport uses TIWAppForm which IIRC are incompatible with PageMode IntraWeb applications. It's not that big of deal since I would guess 90% of IW apps are AppMode.

I think it would be better to remove the madIWSupport unit entirely if the "show exception box" is unchecked.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

bmoelk wrote:I'll have to check tomorrow, but this may still push the report to the client. This is still something we don't want to do.
You could in your exception handler set "handled := true", then madExcept doesn't send anything to the client (even with ShowExceptionBox = true). Also setting ShowExceptionBox := false should result in that the bugReport is not sent to the client anymore. However, in both cases you still have no direct access to the TIWApplication object...
bmoelk wrote:I'll try this:

// dontTouchUses

Will Delphi like it as you add/remove files to the project?
Yes, if you really put it above the uses clause and not inside.
bmoelk wrote:madIWSupport uses TIWAppForm which IIRC are incompatible with PageMode IntraWeb applications. It's not that big of deal since I would guess 90% of IW apps are AppMode.
Will check that, thanks for the hint...
bmoelk wrote:I think it would be better to remove the madIWSupport unit entirely if the "show exception box" is unchecked.
Well, I want madExcept to work automagically by default. If a new user writes his first IW project with madExcept, it's supposed to "just work". The user will expect to be able to call RegisterExceptionHandler and automatically get access to the exceptions. So I don't like the idea of removing madIWSupport even if "show exception box" is unchecked. However, I'll consider adding an option to madExcept to turn off the automatic addition of madIWSupport to IW projects.
Post Reply