title: Localization of Exception Message inside class files?
body: <p>If a class file contains some initial validation and throws an <code>Exception</code> in the case where validation fails, </p>
  
  <ul>
  <li><p>is it considered good practice to enable localization inside the class files for the <code>Exception Message</code>?</p></li>
  <li><p>How would I catch these localized exceptions? Simple string comparison of the <code>Exception Message</code> seems... not elegant to say the least. Are there preferred and proven better ways to approach this?</p></li>
  </ul>
  
  <p>an example of how I was planning this:</p>
  
  <pre><code>private ResourceManager localization;
  
  private string email;
  
  public string Email
  {
      get { return email; }
      set
      {
          if (value.Length &gt; 50)
              throw new ArgumentException(localization.GetString("toolong_email"));
          else if (!IsValidEmail(value))
              throw new ArgumentException(localization.GetString("invalid_email"));
          else
              email = value;
      }
  }
  </code></pre>
  
  <p>Microsoft's <a href="http://msdn.microsoft.com/en-us/library/seyhszts%28v=vs.71%29.aspx" rel="nofollow">Best Practices for Handling Exceptions</a> states: "Include a localized description string in every exception."</p>
  
  <p>I've tagged this C# but in the end this is more about general practices, I suppose. I was thinking that this might be more of a <em>programmers.stackexchange</em> question but decided to post it here. Unsure.</p>