Avoid throwing a new exception

Posted by GustlyWind on Stack Overflow See other posts from Stack Overflow or by GustlyWind
Published on 2008-09-30T11:50:43Z Indexed on 2010/05/09 20:38 UTC
Read the original article Hit count: 276

Filed under:

I have an if condition which checks for value and the it throws new NumberFormatException

Is there any other way to code this

if (foo)
{
    throw new NumberFormatException
}

// ..

catch (NumberFormatException exc)
{
    // some msg...
}

© Stack Overflow or respective owner

Related posts about exception-handling