ComponentPro UltimateTemplateEngine

      Handling Exceptions

      Language Filter: AllSend comments on this topic to ComponentPro

      Handling Exceptions in UltimateTemplateEngine

      When calling LoadFromString, LoadFromStream, LoadFromFile, LoadTemplateClassFromFile, LoadTemplateClassFromStream, LoadTemplateClassFromString, Run and UltimateTemplateEngine constructor, you should consider to catch the exceptions listed below:

      1. TemplateEngineException
      2. ArgumentException
      3. ArgumentNullException
      4. IO Exceptions

      Example below shows how to handle these exceptions:

      Source Code

      using System;
      using ComponentPro;
      
      ...
      
      TemplateEngine dt = new TemplateEngine();
      try
      {
          dt.LoadFromFile("Template.tpl");
      }
      catch (TemplateEngineException exc)
      {
          Console.WriteLine(exc.Message);
          return;
      }
      
      string output = dt.Run();
      Console.WriteLine(output);