Click here to Skip to main content
15,891,567 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.

 
RantMultiple Catch blocks that do the same thing... Pin
jeeves7720-Jun-15 3:06
jeeves7720-Jun-15 3:06 
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 
It doesn't matter.

Regardless of what exception is thrown, the code executed will be identical. Which means that the separate catch for the "lesser" exception need not be there at all.
And if it needed be there, why put it in? All that does is leave a "hole" where duplicated code can become different over time and cause other problems - that's one of the advantages of inheritance: it removes the need to "copy and paste" code by reusing a single method in all derived classes. So if the method needs to be changed, it's in one single place instead of scattered all over the file and prone to being missed when the updates are done.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

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 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465222-Jun-15 4:51
Member 1139465222-Jun-15 4:51 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Sascha Lefèvre22-Jun-15 4:56
professionalSascha Lefèvre22-Jun-15 4:56 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465222-Jun-15 5:40
Member 1139465222-Jun-15 5:40 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
OriginalGriff20-Jun-15 8:09
mveOriginalGriff20-Jun-15 8:09 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Member 1139465222-Jun-15 4:27
Member 1139465222-Jun-15 4:27 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Sascha Lefèvre20-Jun-15 4:44
professionalSascha Lefèvre20-Jun-15 4:44 
GeneralRe: Multiple Catch blocks that do the same thing... Pin
Vikram A Punathambekar20-Jun-15 6:31
Vikram A Punathambekar20-Jun-15 6:31 

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.