Sage.SageException.Render C# (CSharp) Method

Render() public method

Renders the exception to the specified writer
public Render ( TextWriter writer, SageContext context ) : void
writer System.IO.TextWriter The writer to render the exception to.
context SageContext The context under which this code is executing.
return void
        public virtual void Render(TextWriter writer, SageContext context)
        {
            Contract.Requires<ArgumentNullException>(context != null);
            Contract.Requires<ArgumentNullException>(writer != null);

            XmlDocument document = new XmlDocument();
            XmlElement documentElement = document.AppendElement(this.ConvertToXml(this.Exception, document));
            Exception inner = this.Exception.InnerException;

            while (inner != null)
            {
                documentElement.AppendChild(this.ConvertToXml(inner, document));
                inner = inner.InnerException;
            }

            documentElement.AppendChild(context.ToXml(document));
            documentElement.SetAttribute("date", DateTime.Now.ToString("dd-MM-yyyy"));
            documentElement.SetAttribute("time", DateTime.Now.ToString("hh:mm:ss"));

            XsltTransform processor = XsltTransform.Create(context, this.StylesheetPath);
            XmlWriter xmlwr = XmlWriter.Create(writer, processor.OutputSettings);

            processor.Transform(documentElement, xmlwr, context, this.GetTransformArguments(context));
        }