Skip to content

Instantly share code, notes, and snippets.

@skurfuerst
Created October 5, 2023 11:29
Show Gist options
  • Save skurfuerst/8c82e303689cebe2bce9ee9f5f1e9a16 to your computer and use it in GitHub Desktop.
Save skurfuerst/8c82e303689cebe2bce9ee9f5f1e9a16 to your computer and use it in GitHub Desktop.
Custom Throwable Storage to prevent exceptions
<?php
namespace MyPackage\Site;
use Neos\Flow\Log\ThrowableStorage\FileStorage;
use Neos\Media\Exception\NoThumbnailAvailableException;
/*
After implementing Kaleidoscope for Images and SourceSets we got an uncontrollably growing exception folder
when testing with prod-db-dump on staging, which caused a content-release
to fail and made the neos-container grow infiniteley.
We do not longer log this specific Exception, but it will be shown on the page, if it occurs.
*/
class CustomThrowableStorage extends FileStorage {
public function logThrowable(\Throwable $throwable, array $additionalData = []) {
if($throwable instanceof NoThumbnailAvailableException) {
return '';
}
return parent::logThrowable($throwable, $additionalData);
}
}
Neos:
Flow:
log:
# This block is needed for overwriting the ThrowableStorage to our own CustomThrowableStorage.
# For Documentation see: MyPackage/Site/Classes/CustomThrowableStorage.php
throwables:
storageClass: MyPackage\Site\CustomThrowableStorage
renderRequestInformation: true
optionsByImplementation:
'MyPackage\Site\CustomThrowableStorage':
storagePath: '%FLOW_PATH_DATA%Logs/Exceptions'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment