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

 
GeneralOi! Greg Utas! Pin
OriginalGriff29-Mar-21 23:44
mveOriginalGriff29-Mar-21 23:44 
GeneralRe: Oi! Greg Utas! Pin
pkfox29-Mar-21 23:54
professionalpkfox29-Mar-21 23:54 
GeneralWell, I'm way better than yesterday. Pin
OriginalGriff29-Mar-21 21:52
mveOriginalGriff29-Mar-21 21:52 
GeneralRe: Well, I'm way better than yesterday. Pin
pkfox29-Mar-21 22:20
professionalpkfox29-Mar-21 22:20 
GeneralRe: Well, I'm way better than yesterday. Pin
Rage29-Mar-21 23:46
professionalRage29-Mar-21 23:46 
GeneralRe: Well, I'm way better than yesterday. Pin
Rich Leyshon30-Mar-21 0:30
Rich Leyshon30-Mar-21 0:30 
GeneralSome C# code that makes me sick... Pin
Super Lloyd29-Mar-21 15:10
Super Lloyd29-Mar-21 15:10 
GeneralRe: Some C# code that makes me sick... PinPopular
honey the codewitch29-Mar-21 19:31
mvahoney the codewitch29-Mar-21 19:31 
I agree that it should probably be something more like:

C#
// TODO: Log an error
try {
   DoX();
}
catch {
   throw;
}


because that will preserve the error, while still putting in an opportunity to add logging, and kind of a placeholder in the code. Avoiding catching the exception type not only makes explicit that you don't care what kind of exception it is, it also forces you to define your exceptions once you add logging. After all you can't log an exception if you don't capture it in a type, so when you do get around to logging it forces you to consider your exception types at that point, leading to at least a half step toward solving your second complaint about throwing a zillion errors, because you're more selective about what you throw.

However, I'd argue the above is probably not worth it, but I think that comes down to a matter of style. I certainly wouldn't balk at the above code, but I probably wouldn't write it myself.
Real programmers use butterflies

AnswerRe: Some C# code that makes me sick... Pin
Super Lloyd29-Mar-21 21:38
Super Lloyd29-Mar-21 21:38 
GeneralRe: Some C# code that makes me sick... Pin
Rage29-Mar-21 23:48
professionalRage29-Mar-21 23:48 
GeneralRe: Some C# code that makes me sick... Pin
Super Lloyd30-Mar-21 0:26
Super Lloyd30-Mar-21 0:26 
GeneralRe: Some C# code that makes me sick... Pin
milo-xml31-Mar-21 10:09
professionalmilo-xml31-Mar-21 10:09 
JokeRe: Some C# code that makes me sick... PinPopular
Sander Rossel29-Mar-21 19:50
professionalSander Rossel29-Mar-21 19:50 
GeneralRe: Some C# code that makes me sick... Pin
Super Lloyd29-Mar-21 21:39
Super Lloyd29-Mar-21 21:39 
GeneralRe: Some C# code that makes me sick... Pin
Member 1488595529-Mar-21 22:17
Member 1488595529-Mar-21 22:17 
GeneralRe: Some C# code that makes me sick... Pin
dandy7230-Mar-21 3:14
dandy7230-Mar-21 3:14 
GeneralRe: Some C# code that makes me sick... Pin
Sander Rossel30-Mar-21 11:08
professionalSander Rossel30-Mar-21 11:08 
GeneralRe: Some C# code that makes me sick... Pin
Dean Allcorn29-Mar-21 20:44
Dean Allcorn29-Mar-21 20:44 
GeneralRe: Some C# code that makes me sick... Pin
Richard Deeming29-Mar-21 21:48
mveRichard Deeming29-Mar-21 21:48 
GeneralRe: Some C# code that makes me sick... Pin
Super Lloyd30-Mar-21 0:29
Super Lloyd30-Mar-21 0:29 
GeneralRe: Some C# code that makes me sick... Pin
Richard Deeming30-Mar-21 0:44
mveRichard Deeming30-Mar-21 0:44 
GeneralRe: Some C# code that makes me sick... Pin
Super Lloyd30-Mar-21 1:07
Super Lloyd30-Mar-21 1:07 
GeneralRe: Some C# code that makes me sick... Pin
dandy7230-Mar-21 3:17
dandy7230-Mar-21 3:17 
GeneralRe: Some C# code that makes me sick... Pin
MSBassSinger30-Mar-21 3:56
professionalMSBassSinger30-Mar-21 3:56 
GeneralRe: Some C# code that makes me sick... Pin
Slacker00730-Mar-21 4:17
professionalSlacker00730-Mar-21 4:17 

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.