title: What is the preferred method for handling unexpected enum values?
body: <p>Suppose we have a method that accepts a value of an enumeration. After this method checks that the value is valid, it <code>switch</code>es over the possible values. So the question is, what is the preferred method of handling unexpected values <em>after</em> the value range has been validated?</p>
  
  <p>For example:</p>
  
  <pre><code>enum Mood { Happy, Sad }
  
  public void PrintMood(Mood mood)
  {
      if (!Enum.IsDefined(typeof(Mood), mood))
      {
          throw new ArgumentOutOfRangeException("mood");
      }
  
      switch (mood)
      {
          case Happy: Console.WriteLine("I am happy"); break;
          case Sad:   Console.WriteLine("I am sad"); break;
          default: // what should we do here?
      }
  </code></pre>
  
  <p>What is the preferred method of handling the <code>default</code> case?</p>
  
  <ul>
  <li>Leave a comment like <code>// can never happen</code></li>
  <li><code>Debug.Fail()</code> (or <code>Debug.Assert(false)</code>)</li>
  <li><code>throw new NotImplementedException()</code> (or any other exception)</li>
  <li>Some other way I haven't thought of</li>
  </ul>