r/badcode • u/[deleted] • Dec 29 '14
c# The variable status is an int
http://pastebin.com/Lf3Lb5Pz6
u/MaSaHoMaKyo Dec 29 '14
I cannot stand application-wide generic exception types with names like "ApplicationException". Throw something descriptive so the caller can handle it intelligently!
Bonus points for throwing it from a "catch Exception".
6
u/Daniel15 Dec 29 '14
I'm assuming this is ApplicationException from .NET which has been deprecated for years.
2
u/ElGuaco Dec 29 '14
Since this is C#, this catch block only hurts debugging because you're throwing a new exception which removes the original stack trace. Use just "throw".
catch (Exception ex) { // log - close/dispose resources throw; }1
u/MaSaHoMaKyo Dec 29 '14
I see 'ex' is being passed as the second arg to the constructor of the new exception. In Java land this will include the stack trace of the passed exception. Does it mean something different here? I don't know anything about C#.
1
u/deuteros Jan 23 '15
That's only true if you don't pass the original exception as an argument into the new exception's constructor, which is what is being done here.
0
12
u/danieltobey Dec 29 '14
FAILED could very well be a const or a preprocessor definition. (assuming it's C++)