log_not_found off;
deny all;
}
-
+
location ~ ~$ {
# deny access to temp editor files, e.g. "script.php~"
access_log off;
include fastcgi.conf;
}
+ location ~ /doc/ {
+ default_type "text/html";
+ try_files $uri $uri/ $uri.html =404;
+ }
+
location ~ \.php$ {
# deny access to all other PHP scripts
deny all;
{
return dn__($domain, $text, $nText, $nb);
}
+
+/**
+ * Converts an exception into a printable stack trace string.
+ */
+function exception2text(Throwable $e): string
+{
+ return $e->getMessage() . PHP_EOL . $e->getFile() . $e->getLine() . PHP_EOL . $e->getTraceAsString();
+}
+
// 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())
- );
+ $this->assignView('stacktrace', exception2text($throwable));
} else {
$this->assignView('message', t('An unexpected error occurred.'));
}
deny all;
}
+ location ~ /doc/ {
+ default_type "text/html";
+ try_files $uri $uri/ $uri.html =404;
+ }
+
location = /favicon.ico {
# serve the Shaarli favicon from its custom location
alias /var/www/shaarli/images/favicon.ico;
$this->get('/history', '\Shaarli\Api\Controllers\HistoryController:getHistory')->setName('getHistory');
})->add('\Shaarli\Api\ApiMiddleware');
-$response = $app->run(true);
-
-$app->respond($response);
+try {
+ $response = $app->run(true);
+ $app->respond($response);
+} catch (Throwable $e) {
+ die(nl2br(
+ 'An unexpected error happened, and the error template could not be displayed.' . PHP_EOL . PHP_EOL .
+ exception2text($e)
+ ));
+}