An open API service indexing awesome lists of open source software.

https://github.com/formapro/fpbadaboombundle

wise error catcher
https://github.com/formapro/fpbadaboombundle

Last synced: about 1 year ago
JSON representation

wise error catcher

Awesome Lists containing this project

README

          

# FpBadaBoomBundle [![Build Status](https://secure.travis-ci.org/formapro/FpBadaBoomBundle.png?branch=master)](http://travis-ci.org/formapro/FpBadaBoomBundle)

An example of AppKernel

```php
exceptionCatcher, $this->chainNodeManager),

//...
);

return $bundles;
}

/**
* {@inheritDoc}
*/
public function init()
{
$this->exceptionCatcher = new ExceptionCatcher;
$this->chainNodeManager = new SafeChainNodeManager;

$this->exceptionCatcher->start($this->isDebug());

$this->initializeChainNodeManager();

foreach ($this->chainNodeManager->all() as $chainNode) {
$this->exceptionCatcher->registerChainNode($chainNode);
}
}

protected function initializeChainNodeManager()
{
if (extension_loaded('newrelic')) {
$this->chainNodeManager->addSender('default', new NewrelicSender());
}

$this->symfonyExceptionHandlerChainNode = new SymfonyExceptionHandlerChainNode($this->isDebug());
$this->chainNodeManager->addSender('default', $this->symfonyExceptionHandlerChainNode);

$this->chainNodeManager->addFilter('default', new DuplicateExceptionFilter(new ArrayCacheAdapter));

// prod env
if (false == $this->isDebug()) {
$recipients = array(
'dev@example.com',
);

$this->chainNodeManager->addProvider('default', new ExceptionSubjectProvider());
$this->chainNodeManager->addProvider('default', new ExceptionSummaryProvider());
$this->chainNodeManager->addProvider('default', new ExceptionStackTraceProvider());
$this->chainNodeManager->addProvider('default', new ServerProvider());
$this->chainNodeManager->addProvider('default', new SessionProvider());
$this->chainNodeManager->addProvider('default', new EnvironmentProvider());

$serializer = new Serializer(
[new RecursionSafeContextNormalizer],
[new TextEncoder, new LineEncoder]
);

touch($logFile = $this->getRootDir().'/logs/'.$this->getEnvironment().'-exceptions.log');
$this->chainNodeManager->addSender('default', new LogSender(
new NativeLoggerAdapter($logFile),
$serializer,
new DataHolder(array(
'format' => 'line'
))
));

$domain = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'example.com';
$this->chainNodeManager->addSender('default', new MailSender(
new NativeMailerAdapter,
$serializer,
new DataHolder(array(
'sender' => 'noreply@'.$domain,
'recipients' => $recipients,
'subject' => 'Whoops, looks like something went wrong.',
'format' => 'text',
'headers' => array()
))
));
if (isset($_SERVER['SENTRY_DSN'])) {
$this->chainNodeManager->addSender(
'default',
new SentrySender(new \Raven_Client($_SERVER['SENTRY_DSN']))
);
}
}
}

/**
* {@inheritDoc}
*/
public function boot()
{
parent::boot();

$this->symfonyExceptionHandlerChainNode->setEnabled(false);
}
}
```