doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

Document when PHP automatically sets the $previous value in new Throwables

Open lpd-au opened this issue 1 year ago • 0 comments

As far as I see, php.net doesn't document in what circumstances the $previous value is automatically set when the caller doesn't provide one in the Exception/Error constructor. As far as I know, that happens when new exceptions are thrown in finally blocks, in deconstructors and I guess in any other code somehow run outside of a catch block while the Throwable is still bubbling up the call stack. I expected to find that mentioned in one or more of these pages:

  • https://www.php.net/manual/en/language.exceptions.php
  • https://www.php.net/manual/en/exception.construct.php
  • https://www.php.net/manual/en/error.construct.php
  • https://www.php.net/manual/en/throwable.getprevious.php
  • https://www.php.net/manual/en/exception.getprevious.php
  • https://www.php.net/manual/en/error.getprevious.php
  • https://www.php.net/manual/en/class.exception.php#exception.props.previous
  • https://www.php.net/manual/en/class.error.php#error.props.previous

lpd-au avatar Aug 13 '24 15:08 lpd-au