title: #if DEBUG for exception handling
body: <p>I have a public method <code>ChangeLanguage</code> that is in a class library that is supposed to be used by other people who have no idea what the source code is but know what it can do.</p>
  
  <pre><code>public string ChangeLanguage(string language) 
  {
      #if DEBUG
          // Check if the new language is not null or an empty string.
          language.ThrowArgumentNullExceptionIfNullOrEmpty("language", GetString("0x000000069"));
      #else
          if (string.IsNullOrEmpty(language))
              language = _fallbackLanguage;
      #endif 
  }
  </code></pre>
  
  <p>For me it looked obvious to check if a <code>language</code> was actually passed to the method and if not, throw an error to the developer. Tho this is a very small performance loss, I think it's better to not throw an exception but just use the fallback language when no language was provided.</p>
  
  <p>I'm wondering if this is a good design approach and if I should keep using it at other places in the library like here:</p>
  
  <pre><code>    _appResDicSource = Path.Combine("\\" + _projectName + ";component", _languagesDirectoryName, _fileBaseName + "_" + language + ".xaml");
      _clsLibResDicSource = "\\Noru.Base;component\\Languages\\Language_" + language + ".xaml";
  
      ResourceDictionary applicationResourceDictionary;
      ResourceDictionary classLibraryResourceDictionary;
  
      try { applicationResourceDictionary = new ResourceDictionary { Source = new Uri(_appResDicSource, UriKind.RelativeOrAbsolute) }; }
      catch
      {
  #if DEBUG
          throw new IOException(string.Format(GetString("1x00000006A"), _appResDicSource));
  #else
          return ChangeLanguage(_fallbackLanguage);
  #endif
      }
      try { classLibraryResourceDictionary = new ResourceDictionary { Source = new Uri(_clsLibResDicSource, UriKind.RelativeOrAbsolute) }; }
      catch
      {
  #if DEBUG
          throw new IOException(string.Format(GetString("1x00000006B"), _clsLibResDicSource));
  #else
          return ChangeLanguage(_fallbackLanguage);
  #endif
      }
  </code></pre>