Browse Source

Add OnSectionRenderingErrorAsync and slow down with crawling

pull/20463/head
liangshiwei 2 years ago
parent
commit
6ae066d1e9
  1. 21
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

21
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@ -549,12 +550,7 @@ namespace Volo.Docs.Pages.Documents.Project
}
catch (Exception e)
{
var message = $"Error occurred during the rendering of this document. The document is not valid: {e.Message}";
Document.Content = $"````txt{Environment.NewLine}{message}{Environment.NewLine}````";
await LocalEventBus.PublishAsync(new DocumentRenderErrorEvent
{
ErrorMessage = message, Name = Document.Name
});
await OnSectionRenderingErrorAsync(e);
}
}
@ -578,6 +574,19 @@ namespace Volo.Docs.Pages.Documents.Project
Document.Content = content;
}
protected async Task OnSectionRenderingErrorAsync(Exception e)
{
var message = $"Error occurred during the rendering of this document. The document is not valid: {e.Message}";
Document.Content = $"````txt{Environment.NewLine}{message}{Environment.NewLine}````";
await LocalEventBus.PublishAsync(new DocumentRenderErrorEvent
{
ErrorMessage = message, Name = Document.Name
});
// Slow down with crawling
HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
private async Task<List<DocumentPartialTemplateContent>> GetDocumentPartialTemplatesAsync()
{

Loading…
Cancel
Save