camelot/thrower
Utility wrappers that replace PHP’s inconsistent error/warning/notice behavior with exception-based throwing. Simplifies common tasks by ensuring functions fail predictably via exceptions (excluding deprecation warnings).
E_NOTICE, E_WARNING) into exceptions, aligning with PSR-3 and Laravel’s exception-handling ecosystem. This reduces inconsistency and improves debugging.E_USER_WARNING to HttpException).error_log() calls with structured exceptions, improving logging consistency (e.g., using Laravel’s Log::error()).trigger_error() with throw new Exception).Throwable provides (e.g., stack traces, context).App\Exceptions\Handler or libraries like whoops.Throwable).set_error_handler() with a queue system.*"This package offers a low-risk, high-reward solution to standardize error handling in our PHP/Laravel applications. By converting inconsistent PHP errors into exceptions, we’ll:
E_NOTICE noise and ensuring all errors are caught as exceptions.500 Internal Server Error for all critical failures).@ operator) and log clutter.
It’s a one-time effort to wrap legacy code, with long-term payoffs in stability and developer productivity. The MIT license and minimal footprint make it a safe, low-overhead investment."**"Problem: Our codebase mixes PHP errors (trigger_error) and exceptions (throw), leading to:
Solution: camelot/thrower is a static utility that:
E_USER_WARNING) into ErrorException or custom throwables.trigger_error() calls with Throwable::error().Throwable::warning()/Throwable::notice() for legacy code.Throwable to add project-specific metadata (e.g., throw Throwable::fromError($e)->withContext(['user_id' => 123])).Tradeoffs:
Next Steps: Pilot in a non-critical module (e.g., admin panel) to measure impact on logs/debugging. Pair with Laravel’s App\Exceptions\Handler to customize error responses (e.g., JSON for APIs, HTML for web)."*
How can I help you explore Laravel packages today?