Skip to content

Commit

Permalink
feat(exception-template): allow to link to specific documentation for…
Browse files Browse the repository at this point in the history
… how to retreive server log

Signed-off-by: Simon L <[email protected]>
  • Loading branch information
szaimen committed Apr 29, 2024
1 parent a2fefbc commit 120b0e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2235,6 +2235,11 @@
*/
'upgrade.cli-upgrade-link' => '',

/**
* Allows to modify the exception server logs documentation link in order to link to a different documentation
*/
'server_logs_documentation ' => '',

/**
* Set this Nextcloud instance to debugging mode
*
Expand Down
3 changes: 3 additions & 0 deletions core/templates/exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ function print_exception(Throwable $e, \OCP\IL10N $l): void {
<p><?php p($l->t('The server was unable to complete your request.')) ?></p>
<p><?php p($l->t('If this happens again, please send the technical details below to the server administrator.')) ?></p>
<p><?php p($l->t('More details can be found in the server log.')) ?></p>
<?php if (isset($_['serverLogsDocumentation ']) && $_['serverLogsDocumentation '] !== ''): ?>
<p><a href="<?php print_unescaped($_['serverLogsDocumentation ']) ?>" target="_blank" rel="noopener"><?php p($l->t('See this documentation how to retreive them.')) ?></a></p>
<?php endif; ?>

<h3><?php p($l->t('Technical details')) ?></h3>
<ul>
Expand Down
2 changes: 2 additions & 0 deletions lib/private/legacy/OC_Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public static function printExceptionErrorPage($exception, $statusCode = 503) {
http_response_code($statusCode);
try {
$debug = \OC::$server->getSystemConfig()->getValue('debug', false);
$serverLogsDocumentation = \OC::$server->getSystemConfig()->getValue('server_logs_documentation', '');
$request = \OC::$server->getRequest();
$content = new \OC_Template('', 'exception', 'error', false);
$content->assign('errorClass', get_class($exception));
Expand All @@ -315,6 +316,7 @@ public static function printExceptionErrorPage($exception, $statusCode = 503) {
$content->assign('line', $exception->getLine());
$content->assign('exception', $exception);
$content->assign('debugMode', $debug);
$content->assign('serverLogsDocumentation', $serverLogsDocumentation);
$content->assign('remoteAddr', $request->getRemoteAddress());
$content->assign('requestID', $request->getId());
$content->printPage();
Expand Down

0 comments on commit 120b0e6

Please sign in to comment.