Solved

How to modify exception messages form origiinal document

Posted on 2004-04-12
19
347 Views
Last Modified: 2010-04-05
Hello!

I use Delphi 5. I try to modify exception messages original document. Because I may code "try .. catch" for every critical parts and it works, but it is not so easy to watch every step in full project . May I modify original exception messages  documents and after that, program could show "my special messages"  during catch error exceptions.
Thanks!

Regards,
abdate
0
Comment
Question by:abdate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 4
19 Comments
 
LVL 11

Assisted Solution

by:shaneholmes
shaneholmes earned 40 total points
ID: 10807335
Yould assign your own OnExecption event to the Application Object, trapping all exceptions at th Application object level.

Then use a Case statement to test for a partuclar Exception and do something.....

Shane

procedure TForm1.MyException(Sender: TObject; E: Exception);
begin
 case E of
  //
 end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 Application.OnException:= MyException;
end;

0
 
LVL 20

Accepted Solution

by:
Madshi earned 40 total points
ID: 10807760
I'm not sure what you mean. Perhaps you should look here:

http://help.madshi.net/madExcept.htm

It's free for non-commercial usage.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10807764
Or, if you need something free for commercial purpose, have a look at the Jedi Debug unit.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:abdate
ID: 10810275
Thanks shanehomes!
I only try to catch some specific Exception message. but I don't know their handle code.
how to know these handle code.

And Thanks Madshi!
Where is Jedi Debug unit?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10811315
Somewhere here:

http://www.delphi-jedi.org/
0
 

Author Comment

by:abdate
ID: 10818702
Thanks Madshi!

I will check delphi-jedi web later.
By the way, I found only E.Classname & E.message I can get from VCL exception. I do't know any error code I can get, do I? May be I could get some other codes from WINAPI?

Regards,
abdate
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10820785
To be honest: I've still not fully understood your original question. Perhaps you can explain it again in other words? Perhaps with some examples?
0
 

Author Comment

by:abdate
ID: 10828342
Thanks Madshi!

I have a project with many different FormStyle forms. I try to find out an easy way to catch and change some specific exception messages such as "ADOQuery1: Dataset not in edit mode or insert mode", "Cannot insert null into..." and etc..

My orginal idea is trying to change SYSUTILS.HPP or any other HPP file, but I cannot locate these "message".
Then I read Borland HELP file, the description is same as you mentioned before. Using this method, I hope to catch exception code instead of exception message because of its too long words. And I am not sure Delphi provide VCL exception code.

Regards,
abdate
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10830522
You're asking for two things now: (1) Change a specific exception message. And (2) catch the exception code. What do you mean with (2)?

It seems like Shane understood you better than I did. His comment could do what you want. In his "TForm1.MyException" you can check out "E.ClassName" and "E.Message". Also you can probably modify "E.Message".
0
 

Author Comment

by:abdate
ID: 10830792
Yes, I prefer to hope someone could tell me how to modify message on HPP file.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10830821
You're talking in riddles to me.
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10910498
Why you gave a grade of C,

My answer was what you were looking for

procedure TForm1.MyException(Sender: TObject; E: Exception);
begin
// SHowMessage(E.Message);
//or

//case E of
//  SOme error : begin
//                      end;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 Application.OnException:= MyException;
end;


Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10910504
Ahhhhh, a newbe - be careful cause with grades like that experts will hesitate to answer you questions...


Shane
0
 

Author Comment

by:abdate
ID: 10910520
Hi, shaneholmes,

I am so Sorry that gave a grade of C,
I suppose someone could answer how to modify HPP file for Exception. By the way, Your answer I got from HELP file.
0
 

Author Comment

by:abdate
ID: 10910544
And I waited for your more detail answer more than 10 days.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10910784
You would have gotten a better answer if you had actually explained your problem in a way that we can understand. As I hinted in my previous comment, I didn't understand (and still don't understand) your problem.
0
 

Author Comment

by:abdate
ID: 10910834
Yes, these answers are not really my requirement and I still accept them because I want to thanks your effort and give my points. Next time I will do my best when I ask.
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10912090
as Madshi said, no one understand what you were talking about -

 HPP file ?

Shane
0
 

Author Comment

by:abdate
ID: 10912493
I am sorry I forgot HPP is not using in Delphi. HPP using in BCB.
By the way, I mean Could I modify some core program in VCL or dcu or Exception handling routines... to change these Eception message.

abdate


 
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question