Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change exeption hierarchy for Aura Exception to LogicException or RuntimeException #151

Open
tored opened this issue Sep 14, 2017 · 0 comments

Comments

@tored
Copy link

tored commented 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

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.

https://stackoverflow.com/a/5586510

@tored 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant