Differentiated Error-Presenters 4xx and 5xx

11 days ago by David Grudl  

Until now, when an error occurred in your application, you had a standard single setting for handling all errors. Nette Application 3.2 allows you to specify different presenters for different types of errors. Specifically, you can have one presenter for BadRequestException (4xx type errors) and another for more serious server errors (5xx).

application:
	errorPresenter:
		4xx: Error4xx
		5xx: Error5xx

For 4xx errors, you can use a fully equipped presenter that displays a friendly message to visitors in the layout of your website, as the application itself is still fully functional. Conversely, for 5xx errors, a minimal presenter is needed because it is unclear exactly what failed in the application.

This new approach allows for direct redirection to a full-fledged presenter for 4xx errors while preserving all persistent parameters and similar features. This differentiation not only enhances user experience by providing appropriate feedback depending on the error type but also helps in maintaining the stability and security of your application during critical failures.