Normally, I\'d do this:
try
{
code
code that might throw an anticipated exception you want to handle
code
code that might throw an anticip
There are time we want to show specific error to user.
try{
try{
... send message
}
catch(exception e){
...log error
...rethrow send related error/show custom error
}
try{
...try to receive response
}
catch(exception e){
...show receive related error
}
//finally close the connection
}finally{
...close connection
}