Document difference between error and exception
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Affected page
https://www.php.net/manual/en/reserved.exceptions.php
Current issue
From https://www.php.net/manual/en/class.error.php and https://www.php.net/manual/en/class.exception.php, it seems that Error is thrown by PHP and Exception is for userland code:
Exception is the base class for all user exceptions.
Error is the base class for all internal PHP errors.
This is not accurate and not complete.
Suggested improvement
PHP also throws Exception subclasses. But the semantic meaning is different, apparently.
https://github.com/php/policies/blob/main/coding-standards-and-naming.rst#throwables
The Error hierarchy MUST NOT be used for errors that are expected to be thrown (and caught) during normal operation of a PHP program.
As an example, a parsing function that is expected to be used with untrusted input must not throw an Error if the input is malformed. Similarly a function that interacts with the network must not throw an Error if the network operation fails. Any Error that is thrown should usually result in a reasonably obvious fix in the PHP program.
Tim also said that Error is not supposed to be caught, only Exception is.
Additional context (optional)
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the affected page, reserved.exceptions.php, and compare its wording with class.error.php and class.exception.php. Read the linked PHP throwable coding standards for the intended distinction, then revise the explanation so it accurately describes when Error and Exception subclasses are used and verify the documentation links and examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 78/100