Click here to Skip to main content
15,891,033 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: I do not believe it. Pin
Andy Brummer20-Jun-15 6:09
sitebuilderAndy Brummer20-Jun-15 6:09 
GeneralRe: I do not believe it. Pin
Marc Clifton20-Jun-15 10:30
mvaMarc Clifton20-Jun-15 10:30 
GeneralRe: I do not believe it. Pin
swampwiz20-Jun-15 13:12
swampwiz20-Jun-15 13:12 
GeneralRe: I do not believe it. Pin
Brisingr Aerowing20-Jun-15 14:13
professionalBrisingr Aerowing20-Jun-15 14:13 
GeneralRe: I do not believe it. Pin
OriginalGriff20-Jun-15 20:31
mveOriginalGriff20-Jun-15 20:31 
GeneralRe: I do not believe it. Pin
Jörgen Andersson20-Jun-15 21:31
professionalJörgen Andersson20-Jun-15 21:31 
GeneralRe: I do not believe it. Pin
OriginalGriff20-Jun-15 21:37
mveOriginalGriff20-Jun-15 21:37 
RantMultiple Catch blocks that do the same thing... Pin
jeeves7720-Jun-15 3:06
jeeves7720-Jun-15 3:06 
Hi CP community.
We hired a guy that did this a while ago. It annoyed me then, and now I have a project that I'm refactoring that lo and behold has it as well.
Maybe I'm missing some recommended practice (I googled it), and I don't mean to start a war or anything. I just don't see an obvious use for things like this. The message is the same when a socket error occurs...
C#
try
{
   DoSomething();
}
catch (SocketException e)
{
   Console.WriteLine(e.Message);
   conn.connecting = false;
}
catch (Exception e)
{
   Console.WriteLine(e.Message);
   conn.connecting = false;
}

What purpose in life, universe, code, etc... does a practice like this serve?!

(Clarification for all of those who've been giving concrete reasons for catching different exception types. I get that. I do that as well.
I'm saying that the guy we hired previously would handle several exception types only to do the same thing as the catch-all block. Literally the same thing. Sometimes he would catch a type only to throw it to the main block doing nothing with the specific type. It bugged the hell out of me.
Now I'm refactoring another project that is completely unrelated and I see a similar practice which made my mind wander to here...)

modified 20-Jun-15 14:01pm.

GeneralRe: Multiple Catch blocks that do the same thing... Pin
Sascha Lefèvre20-Jun-15 3:11
professionalSascha Lefèvre20-Jun-15 3:11 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465220-Jun-15 3:24
Member 1139465220-Jun-15 3:24 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
OriginalGriff20-Jun-15 3:47
mveOriginalGriff20-Jun-15 3:47 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465220-Jun-15 3:57
Member 1139465220-Jun-15 3:57 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Sascha Lefèvre20-Jun-15 4:03
professionalSascha Lefèvre20-Jun-15 4:03 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465220-Jun-15 4:17
Member 1139465220-Jun-15 4:17 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
OriginalGriff20-Jun-15 4:29
mveOriginalGriff20-Jun-15 4:29 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465220-Jun-15 4:47
Member 1139465220-Jun-15 4:47 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
OriginalGriff20-Jun-15 5:08
mveOriginalGriff20-Jun-15 5:08 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465220-Jun-15 5:26
Member 1139465220-Jun-15 5:26 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
OriginalGriff20-Jun-15 5:42
mveOriginalGriff20-Jun-15 5:42 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465220-Jun-15 6:11
Member 1139465220-Jun-15 6:11 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
OriginalGriff20-Jun-15 6:38
mveOriginalGriff20-Jun-15 6:38 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465220-Jun-15 7:26
Member 1139465220-Jun-15 7:26 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Sascha Lefèvre20-Jun-15 7:58
professionalSascha Lefèvre20-Jun-15 7:58 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465222-Jun-15 4:24
Member 1139465222-Jun-15 4:24 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Sascha Lefèvre22-Jun-15 4:44
professionalSascha Lefèvre22-Jun-15 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.