- var_dump: documentation ( source)
<?php
function three() {
throw new RuntimeException('first exception');
}
function two() {
try {
three();
} catch (Throwable $e) {
throw new CustomException('custom', previous: $e);
}
}
function one()
{
two();
}
class CustomException extends Exception
{
public function getFullTrace()
{
return $this->getPrevious()?->getTrace() ?? $this->getTrace();
}
}
try {
one();
} catch (CustomException $e) {
var_dump($e->getFullTrace());
}