-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathProductionExceptionHandler.php
More file actions
36 lines (30 loc) · 1.23 KB
/
ProductionExceptionHandler.php
File metadata and controls
36 lines (30 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace Networkteam\SentryClient\Content;
use Networkteam\SentryClient\Client;
use Networkteam\SentryClient\Service\ConfigurationService;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\AbstractContentObject;
class ProductionExceptionHandler extends \TYPO3\CMS\Frontend\ContentObject\Exception\ProductionExceptionHandler
{
/**
* Handles exceptions thrown during rendering of content objects
* The handler can decide whether to re-throw the exception or
* return a nice error message for production context.
*/
public function handle(
\Exception $exception,
AbstractContentObject $contentObject = null,
$contentObjectConfiguration = []
): string {
if (Environment::getContext()->isDevelopment()) {
throw $exception;
}
$errorMessage = parent::handle($exception, $contentObject, $contentObjectConfiguration);
$eventId = GeneralUtility::makeInstance(Client::class)->captureException($exception);
if (ConfigurationService::showEventId() && ! empty($eventId)) {
return sprintf('%s Event: %s', $errorMessage, $eventId);
}
return $errorMessage;
}
}