How to custom a Exception page?

How to custom a Exception page , with css, js and with the messages that previous page throws ? (says in other way: How to beautify the exception page?)


Hey man

First you need register exception for this we have many options for it, for example Registering it into dispatcher

$di->set('dispatcher', function () {
            $eventsManager = new EventsManager();
            $eventsManager->attach("dispatch", function ($event, $dispatcher, $exception) {
                //controller or action doesn't exist
                $object = $event->getData();
                if ($event->getType() == 'beforeException') {
                    switch ($exception->getCode()) {
                        case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                        case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                                'controller' => 'errors',
                                'action'     => 'index'
                            return false;
                        case Dispatcher::EXCEPTION_CYCLIC_ROUTING:
                                'controller' => 'errors',
                                'action'     => 'show404'
                            return false;

And created a controller name errors and action index or anthing you want to create it



But I think it can resolve the dispatcher error, like handler not found, action not found etc.

How to do with the system exception, like:

if (true) {
    throw new Exception("Error message");

then the "Error message"should displayed in a custom page.