The Weird and The Wonderful
The Weird and The Wonderful forum is a place to post Coding Horrors,
Worst Practices, and the occasional flash of brilliance.
We all come across code that simply boggles the mind. Lazy kludges, embarrasing mistakes, horrid
workarounds and developers just not quite getting it. And then somedays we come across - or write -
the truly sublime.
Post your Best, your worst, and your most interesting. But please - no
programming questions . This forum is purely for amusement and discussions on code snippets. All
actual programming questions will be removed.
|
|
 |

|
try
{
account.Save();
}
catch { ; }
|
|
|
|

|
At least there are comments.
|
|
|
|

|
I can think of a few comments myself...
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|

|
Guess programmer was hungry thats why he "ate" the exception
Always Keep Smiling.
Yours Pankaj Nikam
|
|
|
|

|
Relax.
This is just sweeping under the rug.
It could be worse.
Mislim, dakle jeo sam.
|
|
|
|

|
I'm impressed they wasted the energy on a surplus semicolon.
Software Zen: delete this;
|
|
|
|

|
They might have a style rule that enforces: "catch block cannot be empty" Warning: Empty catch block. ftfy: ";"
|
|
|
|

|
... which just demonstrates how misleading style enforcement can be.
Software Zen: delete this;
|
|
|
|

|
What kills me is the comment. It would have taken the same effort to say Logger.Log(ex);
|
|
|
|

|
I'm trying (in vain so far) to think up any scenario where the context around this might make this o.k. For example, something like:
int pageIndex = 0;
try {
pageIndex = int.TryParse(Request[pageNum])
} catch (Exception e) {
Logger.info("Page Index of " + Request[pageNum] + " invalid, using " + pageIndex.ToString());
}
(Of course, I'd use Int.TryParse instead and null-check the request variable)
But, you get the idea--some scenario where you can continue to operate with default data given an unexpected condition. I can't think of any situation where the missing context makes it o.k. to swallow an exception trying whatever a Save operation does.
|
|
|
|
 |
|
|
General
News
Suggestion
Question
Bug
Answer
Joke
Rant
Admin