 |
madshi.net high quality low level programming
|
| View previous topic :: View next topic |
| Author |
Message |
PhilW
Joined: 02 Jul 2010 Posts: 5 Location: Leicester, UK.
|
Posted: Mon Jul 26, 2010 2:41 pm Post subject: Trying to extract Error type and message from MadException |
|
|
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 |
|
 |
PhilW
Joined: 02 Jul 2010 Posts: 5 Location: Leicester, UK.
|
Posted: Wed Jul 28, 2010 7:26 am Post subject: |
|
|
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 |
|
 |
madshi Site Admin
Joined: 21 Mar 2004 Posts: 5908
|
Posted: Tue Aug 10, 2010 10:40 am Post subject: |
|
|
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 |
|
 |
PhilW
Joined: 02 Jul 2010 Posts: 5 Location: Leicester, UK.
|
Posted: Tue Aug 10, 2010 2:12 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|