yii2-sentry icon indicating copy to clipboard operation
yii2-sentry copied to clipboard

How to ignore yii\web\NotFoundHttpException

Open arkhamvm opened this issue 1 year ago • 5 comments

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

arkhamvm avatar Mar 20 '23 23:03 arkhamvm

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:[email protected]/1',
				    'levels' => ['error', 'warning'],
				    'context' => true,
				    'clientOptions' => ['release' => '[email protected]'],
				    'except' => [
                                        'yii\web\HttpException:404',
                                        'yii\web\HttpException:400',
                                        'yii\web\HttpException:403',
                                ],
			    ],
		    ],
	    ],
    ],
];

Levii22 avatar Apr 26 '23 16:04 Levii22

@Levii22 thanks!

arkhamvm avatar Apr 26 '23 16:04 arkhamvm

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 avatar Aug 25 '23 16:08 kasoft

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',
],

Levii22 avatar Aug 25 '23 16:08 Levii22

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"

kasoft avatar Aug 26 '23 17:08 kasoft