Modifying Route Errors Pages

Although, the shutters handle most of the errors pages that are displayed on the screen using a default error page. The default error page can be modified either by redefining the default error page globally, within a route or by declaring an entirely different error page locally within route shutter methods.

Updating Default Error Page
The default error pages can be updated by creating a new error template file within the directory of the rex template folder with a new name 404.rex.php. This file will be placed directly into the rex/errors directory. Once this is done, then the new 404.rex.php file will automatically replace the default one.

Updating Globally On Routes
The default template pointer can be updated globally for any route using the self::wvm() method. The example below illustrates this.
  <?php 

  use Window;

  class Home extends Window {
    
    function __construct() {
    
        self::wvm('error', 'my-custom-template');

        self::call($this, [

            'home/user' => 'root',

        ])

    }

  }


Updating From Shutter Methods
The shutter methods are configured to update the default error page only once on its acceptable urls. This can be achieved by supplying the ::404 template error key as one of the urls within the acceptable urls. The corresponding method will then be called by the shutter if any error exists rather than call the default error page. The code below reveals how to achieve this:
  <?php 

  use Window;

  class Home extends Window {
    
    function __construct() {

        self::call($this, [

            'home/user' => 'root',

            '::404' => 'error404()',

        ])

    }

    function error404() {

        self::load('errors.error-template', fn() => compile() );

    }

  }

In the image above, the ::404, that is, error404() method will be triggered if the url home/user does not exist.