RFC: 4xx Error rendering in Neos


(Martin Ficzel) #1

Currently Neos renders 404 and 410 status results by default as error messages and relies on external packages to enable things like editable 404 pages.

At the sprint in salzburg we agreed that this should be a feature the core itself offers but we had no favorite way of implementing this yet.

I suggest to implement native error rendering via fusion with the following steps.

  1. Use the fusion path “error” in addition to “root” as second main entry point to fusion in case of an error occurred.

  2. When the “error” path is evaluated the context contains “error”, “site” and “request” since we obviously were not able to determine a matching documentNode.

  3. To actually trigger the fusion rendering special fusion based rendering for the ErrorHandler is defined.

     # the error matcher
     error = Neos.Fusion:Case {
         
         # this is a custom matcher will be rendered if a 404 status  
         # is rendered by fusion, it will detect a document and by 
         # project specific criteria and render it using the "/root" fusion path
         404 {
             condition = ${error.status == 404}
             @context.documentNode = ${q(site).children('[uriPathSegment == 404]').get()}
             @context.node = ${q(site).children('[uriPathSegment == 404]').get()}
             renderPath = '/root' 
         }
         
         # this is the default matcher that would be come with the core 
         # and renders exactly the  same message as today
         default {
             condition = true
             renderer = Neos.Fusion:ErrorMessage {
                 title = ${error.message}
             }
         }
     }

Neos 4.3 LTS Release Planning
Team Unicorn Meeting | 2018-12-13
(Bastian Waidelich) #2

Great idea, I like :slight_smile:


(Sebastian Helzle) #3

Sounds good. Gives a lot of freedom with small amounts of code.


(Daniel Lienert) #4

Hey @martoro,
that’s a really slick solution, I like!

Please extend the RFC to a RFC: 4xx Error rendering in Neos, as handling 403 for example is also important.
Would it make sense, to provide some prototype for that 4xx {} block?


(Aske Ertmann) #5

Like this approach, it’s simple and straight forward. When we’ve discussed this in the past there weren’t really one standard approach to page rendering and such, so creating a solution that fit all was not really doable. However as Neos rendering has changed and matured, that’s now better possible.


(Martin Ficzel) #6

BTW: I will probably not be able to implement this anytime soon as my next topics will be the agency-list and the 4.3 release. I mainly wanted to document the idea and not sit on it. If anyone has an itch to implement it now i am totally fine with it.


(Rene Rehme) #7

Nice! I like that solution. That makes complex error rendering a lot easier.


(Martin Ficzel) #8

Wow, that was fast. I got a prototype ready after two hours. See branch refactorToFusion in Sitegeist.MoveAlong (https://github.com/sitegeist/Sitegeist.MoveAlong/tree/feature/refactorToFusion)

Still cleanup needed but basically it works.


(Martin Ficzel) #9

Short update, Sitegeist.MoveAlong version 5 is released which adds the fusion based 4xx rendering as suggested above. https://github.com/sitegeist/Sitegeist.MoveAlong

After some experience with this we can will start to bring this to the Neos-core.