Article

From:
To:
Greg Lorriman
Subject:
Re: Exceptions vs Error codes
Newsgroup:
borland.public.delphi.objectpascal

Re: Exceptions vs Error codes

Greg

>
>     if not fileExists(edit1.text) then raise exception.create('No such path
> or filename');
>     modalresult:=mrOk;
> end;
>

Why would you need to raise an exception here?  Why not just open a dialog?
Isn't the usual way to handle exceptions with try-except blocks?  The idea
is that you can interrupt the program's normal flow of control by catching
exceptions and performing special handling in those cases, and moving back
to an earlier point in the routine or call stack.  If you are checking a
condition explicitly and the flow continues from there, then I don't see the
need for the raise.  Seems like a waste of resources.

Joe
FYI: When using a '+' or '-', be sure to precede it with a space unless it is the first character. Example: '+delphi -database', not '+delphi-database' (without quotes).
 
 
Originally created by
Tamarack Associates
Mon, 20 May 2024 00:19:07 UTC
Copyright © 2009-2024
HREF Tools Corp.