public function exception(Request $request)
    {
        $ex = $request->getException();
        
        $this->response->setCode(500);
        printf("<h2>%s</h2>", HttpStatus::getStatus(500));
        while ($ex != null) {
            printf("<h3>%s</h3><pre>%s</pre>", $ex->getMessage(), $ex->getTraceAsString());
            $ex = $ex->getPrevious();
        }
    }