Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error trapping 3

Status
Not open for further replies.

cyberant

Programmer
Sep 21, 2003
44
ZA
Hey guys I'm needing some advice on error handling. Is it possible to have a global error handler that will pick up in what procedure an error occured, so I can write this info to a text file somewhere. I've got an app running 24/7 and need to find where errors are occuring on a global scale. To do it procedure by procedure is going to be too timeous an operation.

Thanks!
 
I know you said it's too numerous, but error-trapping is a core component of good program writing.

Using lots of of try..except blocks allows the program not only to log an unexpected error, but also to recover seamlessly so that it can continue running. This is what you should be aiming for.

Technically, the error message the program may be displaying when an exception occurs actually is the global error trapper - the last resort that tells you what happened.
 
I appreciate your advice, my problem is that there are certain inexplicable errors occuring within the program that I would love to be able to trap with conventional try...Except blocks, if only I knew where the errors were occuring. The biggest problem is that these errors appear to be non-reproducable.

I managed to find a link which solved my problem though, check it out, it's actually really handy when you get into the situation of having an application with over 200,000 lines of code and need to find out exactly where the error occured :
Thanks once again
 
great link, I think we'll be using that procedure, very cool!

les
 
I stand corrected - that is an excellent article. Good find.
 
No prob guys, glad I could help... Google rocks!
 
Well - I've had cause to use this, and it hasn't helped in the slightest. I downloaded the source files the article linked to and used them, but as an example, in my code I had a deliberate error:
Code:
var
  c : Integer;
begin
  c := StrToInt('hello');
end;
And the new popup box simply tells me that 'hello' isn't a valid integer, that the error occurred in SysUtils, and quotes a procedure in it (CvtFormat or something) and doesn't give me a line number. Not very useful.

Similarly, this code
Code:
var
  f : Boolean;
begin
  FreeAndNil(f);
end;
tells me that the error occured in TObject.Free and once again doesn't provide a line number.

Anyone had success using this article? Or some suggestions on what I can do to fix it?
 
The link seems good for me too but it's somewhat useless since i've been using EurekaLog for some time now.

It's excellent for finding runtime errors that you cannot find any other way. It gives all sorts of useful information and one of the best being this:

Call Stack Information:
--------------------------------------------------------------------------------------------------
|Address |Module |Unit |Class |Procedure/Method |Line |
--------------------------------------------------------------------------------------------------
|005D468D|LUJA.exe |BaseRow.pas |TBaseRow |AddRow |2889 |
|77D4ADB9|user32.dll | | |CallWindowProcA | |
|77F75DB5|ntdll.dll | | |KiUserApcDispatcher | |
|77E738AC|kernel32.dll| | |RaiseException | |
|005D4628|LUJA.exe |BaseRow.pas |TBaseRow |AddRow |2872 |
|005D4584|LUJA.exe |BaseRow.pas |TBaseRow |AddRow |2849 |
|005FA9AE|LUJA.exe |BaseRow.pas |TLLIST_DETAIL |AddRow |12133|
|007EB4C7|LUJA.exe |TraCreate2.pas |Tfm_TraCreate2 |CreateDetail |1252 |
|007EB582|LUJA.exe |TraCreate2.pas |Tfm_TraCreate2 |CreateList |1276 |
|007EB494|LUJA.exe |TraCreate2.pas |Tfm_TraCreate2 |CreateDetail |1239 |
|007EB5EA|LUJA.exe |TraCreate2.pas |Tfm_TraCreate2 |CreateLoadingLists |1314 |
|007EB5DC|LUJA.exe |TraCreate2.pas |Tfm_TraCreate2 |CreateLoadingLists |1313 |
|007EB0DC|LUJA.exe |TraCreate2.pas |Tfm_TraCreate2 |cxbuCreateClick |1192 |

So i pretty much know all what's going on with my app when the error occurs and before it.

It's not freeware but quite cheap IMHO.

Here's the homepage:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top