Add skip helper function for calling events

This commit is contained in:
crazywhalecc
2026-01-26 00:43:57 +08:00
parent c27ed8b0b4
commit a709221223
3 changed files with 28 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace StaticPHP\DI;
use DI\Container;
use StaticPHP\Exception\SkipException;
use StaticPHP\Exception\SPCInternalException;
/**
@@ -92,7 +93,12 @@ readonly class CallbackInvoker
);
}
return $callback(...$args);
try {
return $callback(...$args);
} catch (SkipException $e) {
logger()->debug("Skipped invocation: {$e->getMessage()}");
return null;
}
}
/**