mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-15 10:13:58 +02:00
Manually implemented #310 from @Trismegiste.
This commit is contained in:
@@ -16,8 +16,8 @@ looking for a mistake and check the docs to see what the error method is for thi
|
||||
obvious.
|
||||
|
||||
Another problem is when classes automatically throw an error to the screen and exit the process. When you do this you
|
||||
stop another developer from being able to dynamically handle that error. Exceptions should be thrown to make a developer aware
|
||||
of an error; they then can choose how to handle this. E.g.:
|
||||
stop another developer from being able to dynamically handle that error. Exceptions should be thrown to make a developer
|
||||
aware of an error; they then can choose how to handle this. E.g.:
|
||||
|
||||
{% highlight php %}
|
||||
<?php
|
||||
@@ -59,7 +59,7 @@ the creation of a <em>lot</em> of custom Exceptions, some of which could have be
|
||||
provided in the [SPL extension][splext].
|
||||
|
||||
If for example you use the `__call()` Magic Method and an invalid method is requested then instead of throwing a standard
|
||||
Exception which is vague, or creating a custom Exception just for that, you could just `throw new BadFunctionCallException;`.
|
||||
Exception which is vague, or creating a custom Exception just for that, you could just `throw new BadMethodCallException;`.
|
||||
|
||||
* [Read about Exceptions][exceptions]
|
||||
* [Read about SPL Exceptions][splexe]
|
||||
|
Reference in New Issue
Block a user