Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ignore yii\web\NotFoundHttpException #67

Open
arkhamvm opened this issue Mar 20, 2023 · 5 comments
Open

How to ignore yii\web\NotFoundHttpException #67

arkhamvm opened this issue Mar 20, 2023 · 5 comments

Comments

@arkhamvm
Copy link

Hi.
How to prevent yii\web\NotFoundHttpException to be sended to Sentry?

@Levii22
Copy link

Levii22 commented Apr 26, 2023

Late reply but in case someone is looking for it too
Use 'except'
Like this

return [
    'components' => [
	    'log' => [
		    'traceLevel' => YII_DEBUG ? 3 : 0,
		    'targets' => [
			    [
				    'class' => 'notamedia\sentry\SentryTarget',
				    'dsn' => 'http://2682ybvhbs347:235vvgy465346@sentry.io/1',
				    'levels' => ['error', 'warning'],
				    'context' => true,
				    'clientOptions' => ['release' => 'my-project-name@2.3.12'],
				    'except' => [
                                        'yii\web\HttpException:404',
                                        'yii\web\HttpException:400',
                                        'yii\web\HttpException:403',
                                ],
			    ],
		    ],
	    ],
    ],
];

@arkhamvm
Copy link
Author

@Levii22 thanks!

@kasoft
Copy link

kasoft commented Aug 25, 2023

I used this except code, but it's not working. I sentry there are still errors showing up "yii\web\NotFoundHttpException". I tried also just "NotFoundHttpException" with no success. Any ideas?

'except' => [
                        'yii\web\NotFoundHttpException',
                        'yii\web\ForbiddenHttpException'
                    ],

@Levii22
Copy link

Levii22 commented Aug 25, 2023

I used this except code, but it's not working. I sentry there are still errors showing up "yii\web\NotFoundHttpException". I tried also just "NotFoundHttpException" with no success. Any ideas?

'except' => [
                        'yii\web\NotFoundHttpException',
                        'yii\web\ForbiddenHttpException'
                    ],

@kasoft
Make sure you have it inside targets
I'm using yii\web\HttpException:404 and yii\web\HttpException:403 and it seems to work fine.
Try it

'except' => [
    'yii\web\HttpException:404',
    'yii\web\HttpException:403',
],

@kasoft
Copy link

kasoft commented Aug 26, 2023

Thanks @Levii22 - seems to work. I was on the wrong track an thougt i put a Yii Path like "yii\web\NotFoundHttpException" in the list, but the working thing is "yii\web\HttpException:404"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants