Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Try/Catch to subclassed Exception type?
Message
From
09/06/2005 07:14:22
 
 
To
09/06/2005 05:15:26
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01021735
Message ID:
01021744
Views:
21
>Is it possible to specify an exception subclass for the Exception objects created by CATCH TO statement?
>
>In other words:
>
>
>local myException as myExceptionClass
>
>try
>  code here ...
>
>catch to myException as myExceptionClass
>  error handling code
>
>endtry
>
>
>Or (as I suspect), CATCH TO only creates objects of the base Exception class?
>

Yes.
Why? Because this open the myExceptionClass instantiation issue.

If myExceptionClass fire a nested error, the C++ routine go out of manage.

A solution is this:
myException=CREATEOB("myExceptionClass")
try
  code here ...

catch to myException ADDITIVE && if myException is a Exception, 
                              && VFP fill it with this context error values, no VFP code run  
                              && at the end, VFP can call a catch event 
endtry
BUT with this restriction: no VFP code run during the filling (not _Assign executed )


>If so, is there any scenario wher eit makes sense to subclass the base Exception class?
>

OOP elegance and speed.
Exception is the VFP baseclass with methods faster to being created.
then:
- Capture the error into a exceptionvar
- use a specific exception class to manage the exceptionvar.

>Thanks,
>Malcolm
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform