BeaconCMS/beacon

General Improvements: Skip invalid pages that fail to load

leandrocp opened this issue · 1 comments

We do validate templates and resources as much as possible but that's not enough since we expose a callback to customize template loading that may fail due to user errors, causing crashes that take the whole site down. Since the pages are lazy loaded, we can't perform checks early in the pipeline being open to such risk.

Now that we support error pages, we'll skip loading such pages and let beacon present a 404 error instead.

So instead of just raising when loading a page at

defp do_load_page(page) do

it will insert a new record in a ETS table storing the page id as key and both the stack trace and exception as value.

This ETS has to be created when the app starts, similar to

:ets.new(:beacon_assets, [:set, :named_table, :public, read_concurrency: true])
and it will look like this:

Table name: beacon_failed_pages
page_id reason
uuid {exception, stack_trace }

Having such feature allow us to display what caused the page to fail.

Related to #35 and BeaconCMS/beacon_live_admin#90

Pages are skipped as this commit b7ed4d5 but the only feedback provided to the user is a log message in the console. We still need to present the error in the admin interface.