<?php $this->i18nTheme('default', 'default'); ?>
<div class="clearfix m-5">
    <div class="alert alert-danger">
        <h1 class="page-header"><?php _e('A 404 error occurred'); ?></h1>
        <p><?php echo $message ?: __('The page request is not found.'); ?></p>
        <p class="text-right">
            <a href="<?php echo Pi::url('www'); ?>">
                <?php echo _escape(Pi::config('sitename')); ?>
            </a>
        </p>
    </div>
    <?php if ('production' == Pi::environment()) return; ?>
    <?php if (!empty($reason)): ?>
        <h2 class="page-header">Additional information:</h2>
        <?php
        $reasonMessage = '';
        switch ($reason) {
            case 'error-controller-cannot-dispatch':
                $reasonMessage = __('The requested controller was unable to dispatch the request.');
                break;
            case 'error-controller-not-found':
                $reasonMessage = __('The requested controller could not be mapped to an existing controller class.');
                break;
            case 'error-controller-invalid':
                $reasonMessage = __('The requested controller was not dispatchable.');
                break;
            case 'error-router-no-match':
                $reasonMessage = __('The requested URL could not be matched by routing.');
                break;
            default:
                $reasonMessage = __('We cannot determine at this time why a 404 was generated.');
                break;
        }
        ?>
        <p><?php echo $reasonMessage; ?></p>
    <?php endif ?>
    <?php if (isset($this->controller) && $this->controller): ?>
        <dl>
            <dt>Controller:</dt>
            <dd><?php echo _escape($this->module . '-' . $this->controller . '-' . $this->action);
                if (isset($this->controller_class)
                    && $this->controller_class
                    && $this->controller_class != $this->controller
                ) {
                    echo ' (resolves to ' . _escape($this->controller_class) . ')';
                }
                ?>
            </dd>
        </dl>
    <?php endif ?>
    <?php if (isset($this->exception) && $this->exception): ?>
        <h2 class="page-header">Exception:</h2>
        <p><?php echo _escape(Pi::service('security')->path($this->exception->getMessage())); ?></p>
        <h3 class="page-header">Stack trace</h3>
        <pre>
    <?php echo Pi::service('security')->path($this->exception->getTraceAsString()); ?>
    </pre>
    <?php endif ?>
</div>