3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyJobHandlerException extends Exception { public function __construct(string $message, public readonly int $jobId, ?\Throwable $previous = null) { parent::__construct($message, previous: $previous); } } function execute_job(int $jobId) { throw new \Exception('execute_job failed'); } function runner() { $jobId = 1; try { execute_job($jobId); } catch (\Throwable $e) { throw new MyJobHandlerException('Wrapping the exception', $jobId, $e); } } runner();
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Fatal error: Uncaught Exception: execute_job failed in /in/2pc2Z:10 Stack trace: #0 /in/2pc2Z(16): execute_job(1) #1 /in/2pc2Z(22): runner() #2 {main} Next MyJobHandlerException: Wrapping the exception in /in/2pc2Z:18 Stack trace: #0 /in/2pc2Z(22): runner() #1 {main} thrown in /in/2pc2Z on line 18
Process exited with code 255.

preferences:
43.33 ms | 406 KiB | 5 Q