DEV Community

Discussion on: What's the weirdest coding practice you've seen?

Collapse
 
idanarye profile image
Idan Arye

Years ago I received an old C# legacy project where every method was catching all exceptions inside it, wrapping them in a new Exception, and rethrowing them:

void Foo(...)
{
    try
    {
        // ...
    }
    catch (Exception e)
    {
        throw new Exception("Exception thrown at Foo", e);
    }
}

void Bar(...)
{
    try
    {
        // ...
    }
    catch (Exception e)
    {
        throw new Exception("Exception thrown at Bar", e);
    }
}

void Baz(...)
{
    try
    {
        // ...
    }
    catch (Exception e)
    {
        throw new Exception("Exception thrown at Foo", e);
    }
}
Collapse
 
elmuerte profile image
Michiel Hendriks

Like Pokemon Exception Handling, and then releasing them again...

Collapse
 
rhymes profile image
rhymes

AHAHHAHAHA