title: Is there a way to return only the function calls that do not throw exceptions with LINQ?
body: <p>I'm getting tossed into an existing codebase, and part of the job is to get the code gradually under test as I make updates. So it's a process of taking something old and ugly and making it nicer.</p>
  
  <p>In this case, there is a code similar to this:</p>
  
  <pre><code>foreach (var thingamajigLocator in thingamajigLocators)
  {
      Thingamajig thingamajig;
      try
      {
          thingamajig = thingamajigservice.GetThingamajig(thingamajigLocator);
      }
      catch
      {
          // exception logged further down, but is rethrown
          continue;
      }
  
      thingamajigCollection.Add(thingamajig);
  }
  </code></pre>
  
  <p>It's ugly and in theory, if the exception is handled further down, it shouldn't be necessary to handle it here, but that's how the code is and currently, it's too much work to handle the service code.</p>
  
  <p>I would love to do something like this:</p>
  
  <pre><code>thingamajigCollection = thingamajigLocators
                              .Select(tl =&gt; thingamajigservice.GetThingamajig(tl))
                              .Where( /* some condition that strips out the ones throwing exceptions */ );
  </code></pre>
  
  <p>Is this possible in any way? Any other suggestions? I can certainly leave the foreach with the try/catch, but it seems like it could be more elegant since I don't care what the actual exception is in this case. Which again, I know is horrible form, and will need to be addressed, but no time for it right now.</p>