You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For 3.x release I would recommend to change the parent class of Aura Exception to LogicException or RuntimeException.
This is what the Java community calls uncecked exceptions and they should not be handled by the caller because you can't do any reasonable recovery from that situation.
In the case for Aura, if you have messed up your SQL query so it is not even runnable is definitely a developer error and should not happen during normal circumstances and therefore cannot be predicted and handled.
This is also why should not document uncecked exceptions in phpdoc because the caller should not bother with them. It should be the job of the top level exception handler to catch any uncecked exceptions. This is why you can configure PHPStorm to ignore LogicException and RuntimeException for automatic documentation of methods. (Editor->Code Style -> PHP -> PHPDoc).
In practice this means that my repositories does not need to document the Aura exception and therefore not forcing the caller of the repository to handle it.
I can of course wrap all Aura calls in a try-catch statement, but to what use? I can't recover from it anyway.
I guess LogicException is the most appropriate exception, but you could argue for RuntimeException if
the query cannot be determined until runtime.
Here's the bottom line guideline: If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception.
The text was updated successfully, but these errors were encountered:
tored
changed the title
Change exeption hierarchy for Aura Exception to LogicExcetpion or RuntimeException
Change exeption hierarchy for Aura Exception to LogicException or RuntimeException
Sep 14, 2017
For 3.x release I would recommend to change the parent class of Aura Exception to LogicException or RuntimeException.
This is what the Java community calls uncecked exceptions and they should not be handled by the caller because you can't do any reasonable recovery from that situation.
In the case for Aura, if you have messed up your SQL query so it is not even runnable is definitely a developer error and should not happen during normal circumstances and therefore cannot be predicted and handled.
This is also why should not document uncecked exceptions in phpdoc because the caller should not bother with them. It should be the job of the top level exception handler to catch any uncecked exceptions. This is why you can configure PHPStorm to ignore LogicException and RuntimeException for automatic documentation of methods. (Editor->Code Style -> PHP -> PHPDoc).
In practice this means that my repositories does not need to document the Aura exception and therefore not forcing the caller of the repository to handle it.
I can of course wrap all Aura calls in a try-catch statement, but to what use? I can't recover from it anyway.
I guess LogicException is the most appropriate exception, but you could argue for RuntimeException if
the query cannot be determined until runtime.
https://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html
https://stackoverflow.com/a/5586510
The text was updated successfully, but these errors were encountered: