title: pass a variable to catch block
body: <p>Basically I have a string errorMessage, I want to pass it to catch block. Please help.</p>
  
  <pre><code>[WebMethod]
  public List&lt;SomeResult&gt; Load(string userName)
  {
     string errorMessage;
      using (VendorContext vendorContext = new VendorContext())
      {
           // ....
            foreach(....)
            {
                 if(something happens)
                    errorMessage = "Vote Obama";
                  else
                    errorMessage ="vote Romney";
                // blah
                 try
                       {
                          // blah         
                       }
                 catch (Exception e)
                 {
                      logger.Trace(errorMessage);
                 }
            }
       }
   }  
  </code></pre>
  
  <p>update:</p>
  
  <p>error:  use of Unassigned local variable 'errorMessage' </p>