title: Handling failures when opening a Revit file (before any transaction)
body: <p>I'm developing a Revit plugin in C# for exporting data from Revit files. This plugin is used through the Design Automation API (i.e. without user interface, obviously). The whole process works fine for some RVT files. Unfortunately, for some other files, the document opening fails <em>before</em> any transaction has started, so I'm struggling to see how I can catch these opening errors (and possibly delete the corresponding failed elements), similarly to what is suggested in the official documentation <em>inside</em> transactions using IFailuresPreprocessor.</p>
  <p>Does anyone have suggestion on how to handle errors during the document opening itself? Sorry if I miss something obvious. Thanks!</p>
  <p>Part of the C# code is available here (basic code, like in the Design Automation tutorials), as well as the error logs.</p>
  <pre><code>    if (data == null) throw new ArgumentNullException(nameof(data));
  
      Application rvtApp = data.RevitApp;
      if (rvtApp == null) throw new InvalidDataException(nameof(rvtApp));
  
      string modelPath = data.FilePath;
      if (String.IsNullOrWhiteSpace(modelPath)) throw new InvalidDataException(nameof(modelPath));
  
      Document doc = data.RevitDoc;
      if (doc == null) throw new InvalidOperationException(&quot;Could not open document.&quot;);
  
      using (Transaction transaction = new Transaction(doc))
      {
          ...
      }
  </code></pre>
  <p>Log report from Design Automation API:</p>
  <pre><code>[03/18/2022 10:18:46] Initialize and  get RCE: (VersionBuild) 22.1.21.13 (VersionNumber) 2022 (SubVersionNumber) 2022.1.2
  [03/18/2022 10:31:11] Failure #0: FailureDefinitionId-'0d5f227d-a4fd-4bc2-b539-1a13cd9a9173', Severity-'Error', Description-'Line is too short.', Resolution-'Delete Element(s)'.
  [03/18/2022 10:31:11] Failure: Unable to continue because of posted errors. Rolling back transaction.
  [03/18/2022 10:31:17] Autodesk.Revit.Exceptions.OperationCanceledException: Opening was canceled.
  [03/18/2022 10:31:17]    at Autodesk.Revit.ApplicationServices.Application.OpenDocumentFile(ModelPath modelPath, OpenOptions openOptions)
  [03/18/2022 10:31:17]    at DesignAutomationFramework.DesignAutomationData..ctor(Application revitApp, String mainModelPath)
  [03/18/2022 10:31:17]    at DesignAutomationFramework.DesignAutomationReadyEventArgs..ctor(Application revitApp, String mainModelPath)
  [03/18/2022 10:31:17]    at DesignAutomationFramework.DesignAutomationBridge.SetDesignAutomationReady(Application revitApp, String mainModelPath)
  [03/18/2022 10:31:17]    at RevitCoreEngineTest.RceConsoleApplication.Program.UserMain(CommandLineArgs cl)
  [03/18/2022 10:31:19] RESULT: Failure - Result of running user app is failure
  [03/18/2022 10:31:19] Finished running.  Process will return: TestError
  </code></pre>