madshi.net Forum Index madshi.net
high quality low level programming
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trying to extract Error type and message from MadException

 
Post new topic   Reply to topic    madshi.net Forum Index -> madExcept
View previous topic :: View next topic  
Author Message
PhilW



Joined: 02 Jul 2010
Posts: 5
Location: Leicester, UK.

PostPosted: Mon Jul 26, 2010 2:41 pm    Post subject: Trying to extract Error type and message from MadException Reply with quote

Hello,

In my applications there is an error logging routine to capture the obvious errors; the task for MadExcept is to handle the unexpected errors. And very nicely it does too, thank you.

However, I would like to record those errors (the type and the message) in the error logging, so I have added the MadExceptionHandler component to my Delphi project, and created an "On Exception" event.

Code:

procedure TMainForm.MadExceptionHandler1Exception(
  const exceptIntf: IMEException; var handled: Boolean);
begin
   //
end;


But I am now stuck since I cannot see how I can access the various parts of the exception object.

I have looked on your Online Documentation, especially the page titled "MadExcept Unit", and it looks very comprehensive, but unfortunately I do not understand it (due to my ignorance, not due to your documentation).

Is it possible you could point me in the right direction to how I can access the MadException object for this task?

Thanks for any advice,
Regards,
PhilW.
Back to top
View user's profile Send private message
PhilW



Joined: 02 Jul 2010
Posts: 5
Location: Leicester, UK.

PostPosted: Wed Jul 28, 2010 7:26 am    Post subject: Reply with quote

Hi, Madshi,

It was a long day. I've slept since then, and when I had another look at the documentation, it all seems a lot clearer.

I am using something like this:
Code:

procedure TMainForm.MadExceptionHandler1Exception(
  const exceptIntf: IMEException; var handled: Boolean);
begin
    LogMessage('My Application',   'MadException:'+exceptIntf.ExceptMessage, True);
end;


I think I was confused with the 'const' parameter declaration, and that the name of the Exception object didn't start with a 'T'.

Sorry to bother you.
Regards,
PhilW.
Back to top
View user's profile Send private message
madshi
Site Admin


Joined: 21 Mar 2004
Posts: 5908

PostPosted: Tue Aug 10, 2010 10:40 am    Post subject: Reply with quote

Hi Phil,

it doesn't start with a "T" because it's an interface and not a type/object. An interface is similar to an object, but it's cleverer because it's reference counted (like Delphi dynamic strings) and so you don't have to deal with manually freeing the interface. Delphi does that automatically when it's not needed, anymore. That's why I like to use interfaces instead of objects.
Back to top
View user's profile Send private message Send e-mail
PhilW



Joined: 02 Jul 2010
Posts: 5
Location: Leicester, UK.

PostPosted: Tue Aug 10, 2010 2:12 pm    Post subject: Reply with quote

Hi, Madshi,

Thanks for the explanation. As you have probably have guessed, I do not use interfaces nor understand them very well, so I found your comments interesting.

Thanks,
PhilW.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    madshi.net Forum Index -> madExcept All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group