What is the right use of try...catch?
I am pretty confused of how/when to use try..catch. I generally work with PHP and Java codes and I do use try catch but I often get confused. What I mean is, should I use try catch for whole piece of code or the only those part of code which are prone to throw exceptions(Like DB Queries, file parsing, threads, etc.. ). But then again I could get exceptions from any part of the code right? Say,I have a simple form job to edit/update which takes a getparam, postParam and updates to database.
Now should I keep all those activity under my try...catch ??? or should I just use try catch for database assuming that it can throw dbExceptions.
What is the right use of try...catch?
===

I am pretty confused of how/when to use try..catch. I generally work with PHP and Java codes and I do use try catch but I often get confused. What I mean is, should I use try catch for whole piece of code or the only those part of code which are prone to throw exceptions(Like DB Queries, file parsing, threads, etc.. ). But then again I could get exceptions from any part of the code right? Say,I have a simple form job to edit/update which takes a getparam, postParam and updates to database.
Now should I keep all those activity under my try...catch ??? or should I just use try catch for database assuming that it can throw dbExceptions.