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: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Tue, 07 Feb 2023 04:24:24 UTC
Copyright © 2009-2023
HREF Tools Corp.