container->pageBuilder->reset(); if ($throwable instanceof ShaarliFrontException) { // Functional error $this->assignView('message', nl2br($throwable->getMessage())); $response = $response->withStatus($throwable->getCode()); } else { // Internal error (any other Throwable) if ($this->container->conf->get('dev.debug', false)) { $this->assignView('message', $throwable->getMessage()); $this->assignView( 'stacktrace', nl2br(get_class($throwable) .': '. PHP_EOL . $throwable->getTraceAsString()) ); } else { $this->assignView('message', t('An unexpected error occurred.')); } $response = $response->withStatus(500); } return $response->write($this->render('error')); } }