A quick note from the road, Sentry is a fantastic error tracking that helps developers monitor and fix crashes in real-time. A few months ago, I created XT Sentry for Joomla for the Joomla Extension Directory (JED), a simple extension to install the client library to integrate the service: https://github.com/anibalsanchez/XT-Sentry-for-Joomla/releases

Integrating Sentry's error handler in Joomla template error page

We have implemented it with great success on Joomla Extension Directory (JED). However, a user reported an error that has not being received in Sentry's reports. Looking for an answer, I've just noticed that errors received and formatted at the template error page are not processed further. To solve this case, this snippet of code can be dropped in the template error.php:


defined('JPATH_SENTRY_BASE') || define('JPATH_SENTRY_BASE', '/home/..../public_html');
require_once JPATH_SENTRY_BASE . '/libraries/xtsentry/vendor/sentry/sentry/lib/Raven/Autoloader.php';
Raven_Autoloader::register();

$client = new Raven_Client('https://...sentry.io/...', array('environment' => 'development'));

$errorHandler = new Raven_ErrorHandler($client);
$exception = new ErrorException(
  $this->error->getMessage(), 
  $this->error->getCode(), 
  E_ERROR, 
  $this->error->getFile(), 
  $this->error->getLine()
);
$errorHandler->handleException($exception, true);

Now, we are happily receiving more errors. Case solved!

Read more

© 2019 Extly, CB - All rights reserved.