public static ErrorFormatter CreateDefault() { var f = new ErrorFormatter(); f.Formatters.Add((e, o) => DotvvmMarkupErrorSection.Create(e)); f.Formatters.Add((e, o) => new ExceptionSectionFormatter(f.LoadException(e), "Raw Stack Trace", "raw_stack_trace")); f.Formatters.Add((e, o) => DictionarySection.Create("Cookies", "cookies", o.Request.Cookies)); f.Formatters.Add((e, o) => DictionarySection.Create("Request Headers", "reqHeaders", o.Request.Headers)); f.AddInfoLoader <ReflectionTypeLoadException>(e => new ExceptionAdditionalInfo { Title = "Loader Exceptions", Objects = e.LoaderExceptions.Select(lde => lde.GetType().Name + ": " + lde.Message).ToArray(), Display = ExceptionAdditionalInfo.DisplayMode.ToString }); f.AddInfoLoader <DotvvmCompilationException>(e => { var info = new ExceptionAdditionalInfo() { Title = "DotVVM Compiler", Objects = null, Display = ExceptionAdditionalInfo.DisplayMode.ToString }; if (e.Tokens != null && e.Tokens.Any()) { info.Objects = new object[] { $"Error in '{string.Concat(e.Tokens.Select(t => t.Text))}' at line {e.Tokens.First().LineNumber} in {e.SystemFileName}" }; } return(info); }); f.AddInfoCollectionLoader <InvalidCommandInvocationException>(e => { if (e.AdditionData == null || !e.AdditionData.Any()) { return(null); } var infos = new List <ExceptionAdditionalInfo>(); foreach (var data in e.AdditionData) { infos.Add(new ExceptionAdditionalInfo() { Title = data.Key, Objects = data.Value, Display = ExceptionAdditionalInfo.DisplayMode.ToHtmlList }); } return(infos); }); return(f); }
public static ErrorFormatter CreateDefault() { var f = new ErrorFormatter(); f.Formatters.Add((e, o) => DotvvmMarkupErrorSection.Create(e)); f.Formatters.Add((e, o) => new ExceptionSectionFormatter { Exception = f.LoadException(e) }); f.Formatters.Add((e, o) => DictionarySection.Create("Cookies", "cookies", o.Request.Cookies)); f.Formatters.Add((e, o) => DictionarySection.Create("Request Headers", "reqHeaders", o.Request.Headers)); f.Formatters.Add((e, o) => DictionarySection.Create("Environment", "env", o.Environment)); f.AddInfoLoader <ReflectionTypeLoadException>(e => new ExceptionAdditionalInfo { Title = "Loader Exceptions", Objects = e.LoaderExceptions.Select(lde => lde.GetType().Name + ": " + lde.Message).ToArray(), Display = ExceptionAdditionalInfo.DisplayMode.ToString }); f.AddInfoLoader <DotvvmCompilationException>(e => { var info = new ExceptionAdditionalInfo() { Title = "DotVVM Compiler", Objects = null, Display = ExceptionAdditionalInfo.DisplayMode.ToString }; if (e.Tokens != null && e.Tokens.Any()) { info.Objects = new object[] { $"Error in '{string.Concat(e.Tokens.Select(t => t.Text))}' at line {e.Tokens.First().LineNumber} in {e.SystemFileName}" }; } return(info); }); return(f); }