Click here to Skip to main content
12,505,881 members (52,732 online)

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, embarrassing 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.

 
GeneralRe: Try/catch block... Pin
Richard Deeming21-Nov-12 2:23
memberRichard Deeming21-Nov-12 2:23 
GeneralRe: Try/catch block... Pin
warriordog21-Nov-12 2:27
memberwarriordog21-Nov-12 2:27 
GeneralRe: Try/catch block... Pin
Reese Currie21-Nov-12 2:52
memberReese Currie21-Nov-12 2:52 
GeneralRe: Try/catch block... Pin
bkebamc21-Nov-12 5:17
memberbkebamc21-Nov-12 5:17 
GeneralRe: Try/catch block... Pin
H.Brydon21-Nov-12 16:34
memberH.Brydon21-Nov-12 16:34 
GeneralRe: Try/catch block... Pin
Bernhard Hiller21-Nov-12 20:27
memberBernhard Hiller21-Nov-12 20:27 
GeneralRe: Try/catch block... Pin
lukeer22-Nov-12 21:06
memberlukeer22-Nov-12 21:06 
GeneralRe: Try/catch block... Pin
KP Lee26-Nov-12 7:41
memberKP Lee26-Nov-12 7:41 
Richard Deeming wrote:
If that's C#, it won't compile; you'll get a "Control cannot leave the body of a finally clause" compiler error.
I had to play around. You can throw an error in the try/catch/finally segments and it will compile. Since I didn't enclose the routine in a try catch, the finally segment did blow up with an unhandled exception. Then I did put it in that logic:
try
{
    int junk = trycat();
}
catch (Exception ex)
{
    Console.WriteLine("caught exception {0}", ex.Message);
    Console.ReadKey();
}
...
static int trycat()
{
    try
    {
        throw (new Exception("Throwing an exception in try block"));
    }
    catch
    {
        throw (new Exception("Throwing an exception in catch block"));
    }
    finally
    {
        throw (new Exception("Throwing an exception in finally block"));
    }
    return 1;
}

GeneralRe: Try/catch block... Pin
Gary R. Wheeler21-Nov-12 4:26
memberGary R. Wheeler21-Nov-12 4:26 
GeneralRe: Try/catch block... PinPopular
PhilLenoir21-Nov-12 6:36
memberPhilLenoir21-Nov-12 6:36 
GeneralRe: Try/catch block... Pin
Zac Greve27-Nov-12 8:24
memberZac Greve27-Nov-12 8:24 
GeneralRe: Try/catch block... Pin
Member 771191721-Nov-12 9:12
memberMember 771191721-Nov-12 9:12 
GeneralRe: Try/catch block... Pin
kakan28-Nov-12 0:46
memberkakan28-Nov-12 0:46 
GeneralRe: Try/catch block... Pin
PIEBALDconsult20-Nov-12 13:30
memberPIEBALDconsult20-Nov-12 13:30 
GeneralRe: Try/catch block... PinPopular
jasperp20-Nov-12 20:56
memberjasperp20-Nov-12 20:56 
GeneralRe: Try/catch block... Pin
spencepk21-Nov-12 4:03
memberspencepk21-Nov-12 4:03 
GeneralRe: Try/catch block... Pin
ProgramFOX21-Nov-12 4:10
memberProgramFOX21-Nov-12 4:10 
GeneralRe: Try/catch block... Pin
RafagaX21-Nov-12 4:28
memberRafagaX21-Nov-12 4:28 
GeneralRe: Try/catch block... Pin
ProgramFOX21-Nov-12 4:32
memberProgramFOX21-Nov-12 4:32 
GeneralRe: Try/catch block... Pin
jnlt21-Nov-12 5:33
memberjnlt21-Nov-12 5:33 
GeneralWhy would you do this to a stored procedure? It never did anything to you. PinPopular
thrakazog15-Nov-12 11:58
memberthrakazog15-Nov-12 11:58 
GeneralRe: Why would you do this to a stored procedure? It never did anything to you. Pin
Zac Greve15-Nov-12 12:48
memberZac Greve15-Nov-12 12:48 
GeneralRe: Why would you do this to a stored procedure? It never did anything to you. PinPopular
jim lahey20-Nov-12 3:41
memberjim lahey20-Nov-12 3:41 
JokeRe: Why would you do this to a stored procedure? It never did anything to you. Pin
Lewis198620-Nov-12 20:50
memberLewis198620-Nov-12 20:50 
GeneralRe: Why would you do this to a stored procedure? It never did anything to you. PinPopular
Pete O'Hanlon20-Nov-12 12:09
protectorPete O'Hanlon20-Nov-12 12:09 

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.


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 27 Sep 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid