Skip to content

Commit 295be55

Browse files
feat(error handler): Catch Throwable and do not use set_error_handler anymore
1 parent 0bc67c7 commit 295be55

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

scripts/auto-prepend/bounce.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@
1313
use CrowdSecBouncer\StandaloneBouncer;
1414

1515
// If there is any technical problem while bouncing, don't block the user.
16-
set_error_handler(function ($errno, $errstr) {
17-
throw new BouncerException("$errstr (Error level: $errno)");
18-
});
1916
try {
2017
$bouncer = new StandaloneBouncer($crowdSecStandaloneBouncerConfig);
2118
$bouncer->run();
2219
} catch (\Throwable $e) {
2320
$displayErrors = $crowdSecStandaloneBouncerConfig['display_errors'] ?? false;
2421
if (true === $displayErrors) {
25-
throw $e;
22+
throw new BouncerException($e->getMessage(), $e->getCode(), $e);
2623
}
27-
}
28-
restore_error_handler();
24+
}

0 commit comments

Comments
 (0)