Skip to content

Commit b2b0ad3

Browse files
committed
Add error types option
According to my pull request: getsentry/sentry-php#369 With this error types options its possible to configure which error types should be reported.
1 parent 29da61e commit b2b0ad3

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,12 @@ sentry:
112112
skip_capture:
113113
- "Symfony\\Component\\HttpKernel\\Exception\\HttpExceptionInterface"
114114
```
115+
116+
### error types
117+
118+
Define which error types should be reported.
119+
120+
```yaml
121+
sentry:
122+
error_types: E_ALL & ~E_DEPRECATED & ~E_NOTICE
123+
```

src/Sentry/SentryBundle/DependencyInjection/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function getConfigTreeBuilder()
3434
->scalarNode('dsn')
3535
->defaultNull()
3636
->end()
37+
->scalarNode('error_types')
38+
->defaultNull()
39+
->end()
3740
->scalarNode('exception_listener')
3841
->defaultValue('Sentry\SentryBundle\EventListener\ExceptionListener')
3942
->end()

src/Sentry/SentryBundle/ErrorTypesParser.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ public function parse()
2828
{
2929
// convert constants to ints
3030
$this->expression = $this->convertErrorConstants($this->expression);
31-
$this->expression = str_replace([",", " "], [".", ""], $this->expression);
31+
$this->expression = str_replace(
32+
array(",", " "),
33+
array(".", ""),
34+
$this->expression
35+
);
3236
// remove anything which could be a security issue
3337
$this->expression = preg_replace("/[^\d.+*%^|&~<>\/()-]/", "", $this->expression);
3438

@@ -56,7 +60,7 @@ private function convertErrorConstants($expression)
5660

5761
/**
5862
* Let PHP compute the prepared expression for us.
59-
*
63+
*
6064
* @param string $expression prepared expression e.g. 32767&~8192&~8
6165
* @return int computed expression e.g. 24567
6266
*/

src/Sentry/SentryBundle/Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
sentry.client:
33
class: '%sentry.client%'
4-
arguments: ['%sentry.dsn%']
4+
arguments: ['%sentry.dsn%', {'error_types': '%sentry.error_types%'}]
55
calls:
66
- [setRelease, ['%sentry.release%']]
77
- [setEnvironment, ['%sentry.environment%']]

src/Sentry/SentryBundle/SentrySymfonyClient.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ class SentrySymfonyClient extends \Raven_Client
66
{
77
public function __construct($dsn=null, $options=array())
88
{
9+
if (array_key_exists('error_types', $options)) {
10+
$exParser = new ErrorTypesParser($options['error_types']);
11+
$options['error_types'] = $exParser->parse();
12+
}
13+
914
$options['sdk'] = array(
1015
'name' => 'sentry-symfony',
1116
'version' => SentryBundle::VERSION,

0 commit comments

Comments
 (0)