OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.36k stars 2.37k forks source link

Liquid error handling #1464

Open paynecrl97 opened 6 years ago

paynecrl97 commented 6 years ago

At the moment, if there's an error when rendering liquid (either a filter throws and exception, or there's a syntax error), one of two things will happen:

1) If the liquid belongs to a LiquidPart- the request will continue and the page will be rendered with the failing part (as like all other parts/drivers if they throw) 1) Or- the user will see the standard white error page

The first scenario is particularly frustrating because it's hard to track down the root cause with little information.

I think that if there's an issue when rendering liquid, we should display the error in a helpful way. Maybe this could be made configurable, so users have the option to choose when liquid errors are displayed, and when they are hidden away.

sebastienros commented 6 years ago

This should probably be triggered by the environment value (Production/Development)

sebastienros commented 6 years ago

And in both cases we log the error from the same logger source

sebastienros commented 6 years ago

Unless we are in preview, where the error should always be displayed, but not logged.

paynecrl97 commented 6 years ago

Actually I found a bug- the error is rendered, but only if the parsed template is not in the cache. If you wait 30 seconds for the LiquidViewTemplate instance to drop out of the cache, the error will appear again.

I'll push a fix up for this issue soon, but I think that liquid error handling is a story in itself to be revisited later.

That's only for parser errors though. Filters that throw an exception don't show their error.