1. Welcome Guest! In order to create a new topic or reply to an existing one, you must register first. It is easy and free. Click here to sign up now!.
    Dismiss Notice

What exception to throw?

Discussion in 'Microsoft News' started by NewsBot, Apr 16, 2008.

  1. NewsBot

    NewsBot I Got News

    Joined:
    Feb 8, 2006
    Messages:
    1,813
    Operating System:
    Windows Vista Home Premium
    I have a method that checks whether a member variable of that class is valid or not (using the string IsNullOrEmpty method) and if it is null or empty throw an exceptuion with a sensible message describing the problem. However I don't know what type of exception to throw (it's not an argument so can't use the ArgumentNullExeption and FxCop is telling me not to use the Exception type), anyone got any ideas?

    Private Function Save() As Boolean

    ******* If String.IsNullOrEmpty(_MemberVariable) Then
    *********** Throw New Exception("Can not save itself without a valid member variable.")
    ******* End If

    End





     

Share This Page