Skip to content

Add flexibility with ResilientExecuteRenderer to allow customized exception behavior #105

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

Closed
sitecorepm opened this issue Mar 31, 2022 · 2 comments

Comments

@sitecorepm
Copy link

sitecorepm commented Mar 31, 2022

Do you want to request a feature or report a bug?
FEATURE

What is the current behavior?
Any exception caught by ResilientExecuteRenderer logs the exception with Log.Error(...)

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected/desired behavior?
Move the Log.Error statement into its own new virtual method (LogException?) to allow it to be easily overridden.

public override void Process(RenderRenderingArgs args)
{
    try
    {
        base.Process(args);
    }
    catch (Exception exception)
    {
        args.Cacheable = false;
        LogException(exception);
        Exception ex = ProcessException(exception);
        RenderingErrorModel model = CreateRenderingErrorModel(args, ex);
        if (!DispatchPossibleModelException(model, args.PageContext.RequestContext, args.Writer))
        {
            DispatchException(model, args.PageContext.RequestContext, args.Writer);
        }
    }
}


protected virtual void LogException(Exception exception)
{
    Log.Error("Error occurred rendering a view.", exception, GetType());
}

I can submit a PR if this seems reasonable.

Please mention your Sitecore version and Synthesis version.
Sitecore 9.3
Synthesis 9.1.0.2

@sitecorepm sitecorepm changed the title Allow more flexibility with ResilientExecuteRenderer to allow customized exception behavior Add flexibility with ResilientExecuteRenderer to allow customized exception behavior Apr 1, 2022
@blipson89
Copy link
Owner

@sitecorepm it's a reasonable request. If you put in a PR, I'll approve it.

Thanks!

@blipson89
Copy link
Owner

Added to 9.1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants