Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Enclose every createobject with try catch?
Message
From
10/04/2018 14:11:59
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01659292
Message ID:
01659294
Views:
72
>Hi,
>
>Do you think it is a good practice to enclose every case where the code opens a form (sample code below) with the Try Catch?
>
>
>local oForm
>oForm = newobject('my_form','my_form_lib.vcx')
>if type('oForm') = "O" and !isnull( oForm)
>   oForm.show()
>endif
>
>
>If there is a problem, whatever, a run-time error happens on NewObject, so checking for type and isnull is of little help. If I enclose the entire code in Try Catch, the error will be displayed.
>
>But I am not sure if adding so much code (in every case) is worth the 'trouble'
>
>TIA

In my Form Handler class, I have a FormOpen method for this. It also make sure that the form is added to the Forms collection, and checks if the form can be opened more than once, plus a few other things.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform