public static DialogResult ShowTemplateError(TemplateCompilationException E, string TemplateFile)
{
using (ExceptionForm F = new ExceptionForm(E, true))
{
// Get our relative path from the program root
string fileRelativePath = TemplateFile.Replace(Program.RootPath, "");
// Set the window properties
F.WindowTitle = "Compile Error";
F.HeaderText = "Template Compile Error";
F.Message = "An error occured while trying to compile the file \"" + Path.GetFileName(fileRelativePath) + "\"";
F.ImgIcon = Properties.Resources.vistaWarning;
if (E.CompilerErrors.Count > 0)
{
StringBuilder builder = new StringBuilder();
// Append each error's details into the Details stringbuilder
foreach (RazorEngineCompilerError error in E.CompilerErrors)
{
builder.AppendLine("Compile Error:");
builder.AppendLine(error.ErrorText);
builder.AppendLine();
builder.AppendLine("Error #: " + error.ErrorNumber);
builder.AppendLine("File: " + fileRelativePath);
builder.AppendLine("Line: " + error.Line);
builder.AppendLine("Column: " + error.Column);
builder.AppendLine();
}
// Set the Details pane contents
F.ExceptionDetails.Text = builder.ToString();
}
else
{
F.ExceptionDetails.Text = E.Message;
}
return F.ShowDialog(false);
}
}