Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DocumentRenderErrorEvent #20463

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -549,12 +550,7 @@ private async Task ConvertDocumentContentToHtmlAsync()
}
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);
}
}

Expand All @@ -578,6 +574,19 @@ await LocalEventBus.PublishAsync(new DocumentRenderErrorEvent

Document.Content = content;
}

protected async Task OnSectionRenderingErrorAsync(Exception e)
realLiangshiwei marked this conversation as resolved.
Show resolved Hide resolved
{
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()
{
Expand Down
Loading