Best use of exception handling
-
here is another gem by my colleague. I believe he was drunk when he wrote this as I don't think he would do this in senses.
Page executingPage = null;
try
{
executingPage = HttpContext.Current.Handler as Page;
}
catch(InvalidCastException ex)
{
executingPage = HttpContext.Current.Handler as Page;
}**
R A M
**
:doh: :sigh: :(( In that order.
-
I know that there are a number of programers that don't understand proper Exception Handling, but this one is really bad. Maybe he was thinking that he should retry? Even then it is not done properly. :sigh:
Just because the code works, it doesn't mean that it is good code.
:laugh: yeahhh.. it won't go in catch block ever.
**
R A M
**
-
here is another gem by my colleague. I believe he was drunk when he wrote this as I don't think he would do this in senses.
Page executingPage = null;
try
{
executingPage = HttpContext.Current.Handler as Page;
}
catch(InvalidCastException ex)
{
executingPage = HttpContext.Current.Handler as Page;
}**
R A M
**
I have an improved version:
Page executingPage = null;
while (true)
{
try
{
executingPage = HttpContext.Current.Handler as Page;
break;
}
catch (InvalidCastException ex)
{
continue;
}
};P :~
-
I have an improved version:
Page executingPage = null;
while (true)
{
try
{
executingPage = HttpContext.Current.Handler as Page;
break;
}
catch (InvalidCastException ex)
{
continue;
}
};P :~
Yep, this should work MUCH better
____________________________________________________________ Be brave little warrior, be VERY brave
-
here is another gem by my colleague. I believe he was drunk when he wrote this as I don't think he would do this in senses.
Page executingPage = null;
try
{
executingPage = HttpContext.Current.Handler as Page;
}
catch(InvalidCastException ex)
{
executingPage = HttpContext.Current.Handler as Page;
}**
R A M
**
lol then what was the use of the variable "ex" he simple don't understand exception handling
Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/
-
here is another gem by my colleague. I believe he was drunk when he wrote this as I don't think he would do this in senses.
Page executingPage = null;
try
{
executingPage = HttpContext.Current.Handler as Page;
}
catch(InvalidCastException ex)
{
executingPage = HttpContext.Current.Handler as Page;
}**
R A M
**
DWC - (Zero tolerance for) drunk while coding...
-
here is another gem by my colleague. I believe he was drunk when he wrote this as I don't think he would do this in senses.
Page executingPage = null;
try
{
executingPage = HttpContext.Current.Handler as Page;
}
catch(InvalidCastException ex)
{
executingPage = HttpContext.Current.Handler as Page;
}**
R A M
**
That's GOT to be a DWC!! :laugh:
Smokie, this is not 'Nam. This is bowling. There are rules. www.geticeberg.com
-
here is another gem by my colleague. I believe he was drunk when he wrote this as I don't think he would do this in senses.
Page executingPage = null;
try
{
executingPage = HttpContext.Current.Handler as Page;
}
catch(InvalidCastException ex)
{
executingPage = HttpContext.Current.Handler as Page;
}**
R A M
**
I once fixed something similar that was coded by a newbie, it went something like this: private void HandleException(Exception ex) { try { ... Code to handle exception that would always throw an exception ... Can't recall exactly what it was since it was 3 years ago } catch (Exception ex) { HandleException(ex); } } The function would recursively call itself and cause a stack overflow exception.
-
That's GOT to be a DWC!! :laugh:
Smokie, this is not 'Nam. This is bowling. There are rules. www.geticeberg.com
-
here is another gem by my colleague. I believe he was drunk when he wrote this as I don't think he would do this in senses.
Page executingPage = null;
try
{
executingPage = HttpContext.Current.Handler as Page;
}
catch(InvalidCastException ex)
{
executingPage = HttpContext.Current.Handler as Page;
}**
R A M
**
-
I have an improved version:
Page executingPage = null;
while (true)
{
try
{
executingPage = HttpContext.Current.Handler as Page;
break;
}
catch (InvalidCastException ex)
{
continue;
}
};P :~