Hello,
For the longest time I've been using try/catch/finally syntax when dealing with database connections. Today I stumbled across the documentation for the "using" keyword (page 126
here and about halfway down the page
here). I really like the brevity and flexibility it offers, but I am concerned about exceptions.
In a normal try/catch/finally block, there is a high degree of control over exceptions. However, for the using clause I am not sure what to do about them. The first documentation link above only alludes to exceptions once in relation to the using clause saying "Gosu disposes of the stream after it completes or if there is an exception."
What if there is an exception connecting to the database or really any other kind of exception at all when working with the database, the prepared statement, the result set, etc.? Is there no way to handle this in whatever way I like? Simply throwing the exception to the next function up seems like passing the buck and defeats the purpose of the brevity this clause appears like it's meant to offer.
Any suggestions?
Thanks,
Jet