public void ErrorFileShouldSaveParseContext()
        {
            var lib = new TagLib();

            lib.Register(new Tags.Tiles());
            lib.Register(new Sharp());
            var factory = new FileLocatorFactory().CloneForTagLib(lib) as FileLocatorFactory;

            try
            {
                new TilesSet();
                var tile = new TemplateTile(
                    "test",
                    factory.Handle("errorinfile.htm", true),
                    null
                    );
            }
            catch (TemplateExceptionWithContext TEWC)
            {
                Assert.That(TEWC.Context, Is.Not.Null);
                Assert.That(TEWC.Context.LineNumber, Is.EqualTo(2));
                string       fullPath     = Path.GetFullPath("errorinfile.htm");
                TagException tagException =
                    TagException.UnbalancedCloseingTag(new ForEach()
                {
                    Group = new Core()
                }, new If()
                {
                    Group = new Core()
                }).Decorate(TEWC.Context);
                Assert.That(TEWC.Message,
                            Is.EqualTo(TemplateExceptionWithContext.ErrorInTemplate(fullPath, tagException).Message));
            }
        }
Example #2
0
 protected override void Load()
 {
     try
     {
         _template = Formatter.LocatorBasedFormatter(_factory.Lib, _name, _locator, _factory).ParsedTemplate;
     }
     catch (ResourceException FNFe)
     {
         throw TemplateException.TemplateFailedToInitialize(_name, FNFe).WithHttpErrorCode(404);
     }
     catch (ExceptionWithContext EWC)
     {
         throw TemplateExceptionWithContext.ErrorInTemplate(_name, EWC).AddErrorCodeIfNull(500);
     }
     catch (Exception e)
     {
         throw TemplateException.ErrorInTemplate(_name, e).WithHttpErrorCode(500);
     }
 }