Need an example of how to use "try" and "catch"
Bob Sneidar
bobs at twft.com
Thu Mar 22 16:25:18 EDT 2012
No advantage per se, but I use sqlYoga and the only way to determine what went wrong is in a try catch statement as the libSQLYoga stack is locked.
Bob
On Mar 22, 2012, at 11:49 AM, Pete wrote:
> Interesting, never thought of that. Is there an advantage to doing that
> over just issuing the database call and checking for an error right after?
>
> I've mostly thought of try/catch for as a debugging tool. I also use it
> any place where I put together a command in a variable and execute the
> command with a do statement.
>
> Pete
>
> On Thu, Mar 22, 2012 at 11:30 AM, Bob Sneidar <bobs at twft.com> wrote:
>
>> I use it to determine if there has been an error executing a sequel query
>> for example. All my database calls go inside a try catch statement. If you
>> put it into a repeat loop, you can test to see if perhaps you have been
>> disconnected, or if a runtime error occurred due to a bad query, and then
>> act accordingly, either try to reconnect if disconnected, or bail out
>> gracefully if a runtime error has occurred.
>>
>> Bob
>>
>>
>> On Mar 22, 2012, at 10:33 AM, Michael Doub wrote:
>>
>>> Does anyone have any guidelines as to when you should use the try and
>> catch structure? I don't really know when or when not to use it.
>>>
>>> -= Mike
>>>
>>>
>>>
>>> On Mar 22, 2012, at 1:21 PM, Jim Hurley wrote:
>>>
>>>> Thanks Peter.
>>>>
>>>> The problem now is what do these bloody error numbers translate into.
>>>> Is the a list somewhere?
>>>>
>>>> When I try:
>>>>
>>>> on mouseUP
>>>> try
>>>> put the cantdelete of me into temp
>>>> catch tErr
>>>> --- if tErr is ??????
>>>> end try
>>>> end mouseUP
>>>>
>>>> I get an error of 348,0,0
>>>>
>>>> Jim
>>>>
>>>>
>>>>
>>>>
>>>>> Peter Brigham wrote:
>>>>>
>>>>> The syntax for the try construction is
>>>>>
>>>>> try
>>>>> <command here>
>>>>> catch tError
>>>>> <other commands here>
>>>>> end try
>>>>>
>>>>> and the error number is put into the variable tError. So the <other
>> commands> could be, eg,
>>>>>
>>>>> if tError = 314 then
>>>>> answer "range error in loading array"
>>>>> else if ...
>>>>> etc.
>>>>> end if
>>>>>
>>>>> -- Peter
>>>>>
>>>>> Peter M. Brigham
>>>>>
>>>>> pmbrig at gmail.com
>>>>> http://home.comcast.net/~pmbrig
>>>>>
>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>
>
> --
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list