How not to catch the exception
-
While looking into some production issues and after much looking into the few functions that span over 700-1000 lines, I stumbled upon the root cause. Oh my what a priceless gem!
private static int somefunction(some params)
{
int iKey = -1;
try
{
//codes transaction
}
catch (SqlException ex)
{
return iKey;
}
catch (Exception ex)
{
return iKey;
}
finally
{
//release or closed whatever
}return iKey;
}
-
While looking into some production issues and after much looking into the few functions that span over 700-1000 lines, I stumbled upon the root cause. Oh my what a priceless gem!
private static int somefunction(some params)
{
int iKey = -1;
try
{
//codes transaction
}
catch (SqlException ex)
{
return iKey;
}
catch (Exception ex)
{
return iKey;
}
finally
{
//release or closed whatever
}return iKey;
}
What a 'crazy code' it is... :omg: Compiler shouldn't have allowed return statements in catch :-D
Understand SOLID! Believe SOLID! Try SOLID! Do implement live SOLID; your Code base becomes Rock SOLID!!! http://www.codeproject.com/Articles/593751/Code-Review-Checklist-and-Guidelines-for-Csharp-De
-
While looking into some production issues and after much looking into the few functions that span over 700-1000 lines, I stumbled upon the root cause. Oh my what a priceless gem!
private static int somefunction(some params)
{
int iKey = -1;
try
{
//codes transaction
}
catch (SqlException ex)
{
return iKey;
}
catch (Exception ex)
{
return iKey;
}
finally
{
//release or closed whatever
}return iKey;
}
-
What a 'crazy code' it is... :omg: Compiler shouldn't have allowed return statements in catch :-D
Understand SOLID! Believe SOLID! Try SOLID! Do implement live SOLID; your Code base becomes Rock SOLID!!! http://www.codeproject.com/Articles/593751/Code-Review-Checklist-and-Guidelines-for-Csharp-De
-
While looking into some production issues and after much looking into the few functions that span over 700-1000 lines, I stumbled upon the root cause. Oh my what a priceless gem!
private static int somefunction(some params)
{
int iKey = -1;
try
{
//codes transaction
}
catch (SqlException ex)
{
return iKey;
}
catch (Exception ex)
{
return iKey;
}
finally
{
//release or closed whatever
}return iKey;
}
I think he missed "return iKey" in the finally clause :^)
-
I think he missed "return iKey" in the finally clause :^)
If it's C#, you can't have a
return
in afinally
clause.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
If it's C#, you can't have a
return
in afinally
clause.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Good "catch" !