0

I am working on a site that has errors, and debug is turned on in the configuration. But all I see is the image below with a bare error and no context. How can I get the usual debug information?

Screenshot of error page

2
  • Do you have Debug set to yes and Error Messages set to Maximum?
    – Irata
    Commented Sep 7, 2023 at 22:05
  • Thanks, yes, I did have debug set. Can't set error messages to maximum - Joomla 3 creates masses of notices on PHP 8.2.
    – mbrampton
    Commented Sep 9, 2023 at 14:32

1 Answer 1

1

It means that the template you're using does not render the stack trace in its error layout. To render the stack trace, use Joomla\CMS\Document\ErrorDocument::renderBacktrace() method. The stack trace should be rendered only when debug is enabled to prevent leaking sensitive data. So at a bare minimum this code can be used inside error.php:

<?php if ($this->debug) : ?>
    <?= $this->renderBacktrace() ?>
<?php endif; ?>

The exception may contain previous exceptions. In which case you should also render them. Something like this should work:

<?php if ($this->debug) : ?>
    <?= $this->renderBacktrace() ?>
    <?php // Loop over exceptions ?>
    <?php while ($error = $this->_error->getPrevious()) : ?>
        <?php // Set the previous exception ?>
        <?php $this->setError($error) ?>
        <p><?= htmlspecialchars($error->getMessage(), ENT_QUOTES, 'UTF-8') ?></p>
        <?= $this->renderBacktrace() ?>
    <?php endwhile ?>
    <?php // Restore the original exception ?>
    <?php $this->setError($this->error) ?>
<?php endif ?>
1
  • Thanks very much. There are a number of files called error.php but I pinned it down to the one that is in a layout belong to the default template. I couldn't implement your solution as the layout appeared not to be inheriting from the Joomla class - renderBacktrace was an unknown method. But I expanded the error message using methods on the exception to get the failing file and line number which was enough to find the problems.
    – mbrampton
    Commented Sep 9, 2023 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.