Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When to THROW exception?
Message
 
To
17/09/2005 21:18:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01050675
Message ID:
01050687
Views:
8
>
> I am new to use TRY...CATCH...ENDTRY statement to handle error.
> In my practise, I always store loexception.message to my object.cErrorMsg
> if any exception catched and passed .T./.F. to calling program.
> Can anyone give me some ideas, when should I THROW the exception
> instead of storing error msg tro property and return boolean to calling prg?
>

Errorhandling works kind of cascading. If no one "here" can handle an error, it's handed up to the next level. Thus You can provide global errorhandling on the top level (let's say the start program) and let specific problems handle by the class that's responsible.

Let's say You have a global procedure to handle a missing or corrupt table. Then You could on the class level perform a simple check like If ! file("xy.dbf")... and if it's not there, let the class say: "This is not my business. I have no Idea who is responsible for this, and so I hand it over to *someone*". The class then throws an exception saying "Hey, could anyone *please* take care of this, I need to do some work here!"

Does this make it clear?
Regards from Berlin

Frank

Dietrich Datentechnik (Berlin)
Softwarekombinat Teltow (Teltow)

Frank.Dietrich@dd-tech.de
DFPUG # 327
Previous
Reply
Map
View

Click here to load this message in the networking platform