2
2
3
3
namespace CrowdSecBouncer ;
4
4
5
- use ErrorException ;
6
5
use Symfony \Component \Cache \Adapter \AbstractAdapter ;
7
6
use Symfony \Component \Cache \Adapter \MemcachedAdapter ;
8
7
use Symfony \Component \Cache \Adapter \PhpFilesAdapter ;
@@ -122,7 +121,7 @@ public function getBouncerInstance(): Bouncer
122
121
$ maxRemediationLevel = Constants::REMEDIATION_BAN ;
123
122
break ;
124
123
default :
125
- throw new Exception ("Unknown $ bouncingLevel " );
124
+ throw new \ Exception ("Unknown $ bouncingLevel " );
126
125
}
127
126
128
127
// Instanciate the bouncer
@@ -344,7 +343,7 @@ public function sendResponse(?string $body, int $statusCode = 200): void
344
343
header ('Pragma: no-cache ' );
345
344
break ;
346
345
default :
347
- throw new Exception ("Unhandled code $ {statusCode}" );
346
+ throw new \ Exception ("Unhandled code $ {statusCode}" );
348
347
}
349
348
if (null !== $ body ) {
350
349
echo $ body ;
@@ -354,10 +353,10 @@ public function sendResponse(?string $body, int $statusCode = 200): void
354
353
355
354
public function safelyBounce (): void
356
355
{
357
- // If there is any technical problem while bouncing, don't block the user. Bypass boucing and log the error.
356
+ // If there is any technical problem while bouncing, don't block the user. Bypass bouncing and log the error.
358
357
try {
359
- set_error_handler (function ($ errno , $ errstr, $ errfile , $ errline ) {
360
- throw new ErrorException ( $ errstr, $ errno , 0 , $ errfile , $ errline );
358
+ set_error_handler (function ($ errno , $ errstr ) {
359
+ throw new BouncerException ( " $ errstr (Error level: $ errno ) " );
361
360
});
362
361
$ this ->run ();
363
362
restore_error_handler ();
0 commit comments