PeterdeB
asked on
Geobul
Hi Folks and\if\or Geobul!
I have been busy with studying exception handling and while walking through replies on questions of mine here at EE I bumped into this answer:
For an exception handling I would use something like:
procedure TForm1.BTNEMO1Click(Sender : TObject);
begin
try
emo1 := emo1 + 1;
...
else
begin
Raise exception.Create('Fout opgetreden'); end;
end; // end of case statement
except
// do something here with the exception like
on E: Exception do ...
end;
end;
Now I'd like to know what there is to do with the exception? Furthermore > if I use the Raise Exception.Create('') then some messagebox pops up asking the user whether to inform me. Clicking yes automatically kicks Outlook out of its lazy chair and fills in the unit name, procedure name and linenumber which causes the headache. Now I assume that that is what you meant by doing something with the exception, right?
Regards Peter
Ps I'm using this codefragment so I'd like to understand it as much as possible.
I have been busy with studying exception handling and while walking through replies on questions of mine here at EE I bumped into this answer:
For an exception handling I would use something like:
procedure TForm1.BTNEMO1Click(Sender
begin
try
emo1 := emo1 + 1;
...
else
begin
Raise exception.Create('Fout opgetreden'); end;
end; // end of case statement
except
// do something here with the exception like
on E: Exception do ...
end;
end;
Now I'd like to know what there is to do with the exception? Furthermore > if I use the Raise Exception.Create('') then some messagebox pops up asking the user whether to inform me. Clicking yes automatically kicks Outlook out of its lazy chair and fills in the unit name, procedure name and linenumber which causes the headache. Now I assume that that is what you meant by doing something with the exception, right?
Regards Peter
Ps I'm using this codefragment so I'd like to understand it as much as possible.
I'm not sure exactly what your question is, but in my opinion it is bad practice to use exceptions to control program flow in the fashion you are describing.
ASKER
Hi StevenB,
Well I'm all ears and would be more than happy to learn about alternatives or other approaches. Geobul just responded to a question of mine in which I had implemented incorrect exceptionhandling. That was part of my question, I asked how I could make sure I'd catch any exceptions that may occur so he among others replied.
Regards,
Peter
Well I'm all ears and would be more than happy to learn about alternatives or other approaches. Geobul just responded to a question of mine in which I had implemented incorrect exceptionhandling. That was part of my question, I asked how I could make sure I'd catch any exceptions that may occur so he among others replied.
Regards,
Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Steven!
After reading 4 times what you posted I think I get the message. Nevertheless your approach raises a question (speaking of raising exceptions :)
I agree on the messagebox being a suitable solution for all kinds of problems and I use it as much as I can. I use it when I need some text from some file > to respond properly when the file may be missing for instance, and so on.
But isn't the use of the messagebox limited to cases in which you know what could be going wrong in advance?
Regards,
Peter
After reading 4 times what you posted I think I get the message. Nevertheless your approach raises a question (speaking of raising exceptions :)
I agree on the messagebox being a suitable solution for all kinds of problems and I use it as much as I can. I use it when I need some text from some file > to respond properly when the file may be missing for instance, and so on.
But isn't the use of the messagebox limited to cases in which you know what could be going wrong in advance?
Regards,
Peter
Take a look here:
http://www.madshi.net/
MadExcept might be of some help.
Some more info here:
http://help.madshi.net/madExcept.htm
Groeten
Ratje
http://www.madshi.net/
MadExcept might be of some help.
Some more info here:
http://help.madshi.net/madExcept.htm
Groeten
Ratje
ASKER
Hi Ratje!
May I ask what exception handling you use or can I assume you use Madshi's?
Regards,
Peter
Is het bij jullie ook zo'n heeeeeerlijk weeeeer als hier?? :)
May I ask what exception handling you use or can I assume you use Madshi's?
Regards,
Peter
Is het bij jullie ook zo'n heeeeeerlijk weeeeer als hier?? :)
Madshi...love that tool :)
PS: Ja zaaaalig weer hier, ga zo maar ff buiten een peukje roken denk ik :)
PS: Ja zaaaalig weer hier, ga zo maar ff buiten een peukje roken denk ik :)
ASKER
Oh okay.....I used Eurekalog for some time and now I use TExceptionManager component because I want to display each and every messagebox or dialog in the same style as my main form, which is skinned-to-da-max :)
Om de een of andere reden lijkt het zo vanzelfsprekend dat de rest niet snapt wat wij schrijven terwijl het aan de andere kant eigenlijk maar moeilijk voor te stellen is dat dit abracadabra zou zijn voor de meesten.....:)
Om de een of andere reden lijkt het zo vanzelfsprekend dat de rest niet snapt wat wij schrijven terwijl het aan de andere kant eigenlijk maar moeilijk voor te stellen is dat dit abracadabra zou zijn voor de meesten.....:)