diff --git a/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs index 6232d868c0..88f5360597 100644 --- a/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs @@ -92,30 +92,26 @@ namespace Microsoft.AspNet.Diagnostics Exception ex, ICompilationException compilationException) { - var stackFrames = new List(); var model = new CompilationErrorPageModel() { Options = _options, - ErrorDetails = new ErrorDetails - { - Error = ex, - StackFrames = stackFrames - } }; - // For view compilation, the most common case is to stop at the first failing file compiled as part of - // rendering a view. Consequently we'll limit ourselves to displaying errors from the first failure. - var failedCompilationFile = compilationException.CompilationFailures.FirstOrDefault(); - if (failedCompilationFile != null) + foreach (var compilationFailure in compilationException.CompilationFailures) { - var fileContent = failedCompilationFile.SourceFileContent + var stackFrames = new List(); + var errorDetails = new ErrorDetails + { + StackFrames = stackFrames + }; + var fileContent = compilationFailure.SourceFileContent .Split(new[] { Environment.NewLine }, StringSplitOptions.None); - foreach (var item in failedCompilationFile.Messages) + foreach (var item in compilationFailure.Messages) { var frame = new StackFrame { - File = failedCompilationFile.SourceFilePath, + File = compilationFailure.SourceFilePath, Line = item.StartLine, Function = string.Empty }; @@ -128,6 +124,8 @@ namespace Microsoft.AspNet.Diagnostics stackFrames.Add(frame); } + + model.ErrorDetails.Add(errorDetails); } var errorPage = new CompilationErrorPage diff --git a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorModel.cs b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorModel.cs index fed8231c1b..6ef439c916 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorModel.cs +++ b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorModel.cs @@ -18,6 +18,6 @@ namespace Microsoft.AspNet.Diagnostics.Views /// /// Detailed information about each parse or compilation error. /// - public ErrorDetails ErrorDetails { get; set; } + public IList ErrorDetails { get; } = new List(); } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs index 4211cd3fc6..5d2268e11a 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs +++ b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs @@ -50,8 +50,6 @@ using Views { #line 10 "CompilationErrorPage.cshtml" - var errorDetail = Model.ErrorDetails; - Response.StatusCode = 500; Response.ContentType = "text/html"; Response.ContentLength = null; // Clear any prior Content-Length @@ -61,26 +59,26 @@ using Views WriteLiteral("\r\n\r\n\r\n \r\n \r\n " + ""); -#line 21 "CompilationErrorPage.cshtml" +#line 19 "CompilationErrorPage.cshtml" Write(Resources.ErrorPageHtml_Title); #line default #line hidden WriteLiteral("\r\n