User tests: Successful: Unsuccessful:
Pull Request for Issue #24887.
Throw exception instead of returning false.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Title |
|
Title |
|
Labels |
Added:
?
|
Does Joomla core handle these exception? If not please also adapt core files.
Not sure what you mean here. Adapt how? With try-catch blocks?
Does Joomla core handle these exception? If not please also adapt core files.
Not sure what you mean here. Adapt how? With try-catch blocks?
It depends on the case if it suites to catch the exception and handle the return better then do nothing then yes.
It depends on the case if it suites to catch the exception and handle the return better then do nothing then yes.
I have honestly no idea on which change would be accepted here: https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Installer/Installer.php#L1727
Is there a try-catch at the top? Should I catch it and ignore the error message in the exception? Should the installer be changed also to throw exceptions at failure instead of returning false?
Instead of consistently re-using the SPL Exceptions, core really needs to get better about introducing Exception subclasses that makes it easier to catch specific error types. A try/catch around a RuntimeException is honestly too vague because so many of the SPL Exceptions are subclasses of that, as well as many of the (albeit limited) Joomla Exception classes.
Instead of consistently re-using the SPL Exceptions, core really needs to get better about introducing Exception subclasses that makes it easier to catch specific error types. A try/catch around a RuntimeException is honestly too vague because so many of the SPL Exceptions are subclasses of that, as well as many of the (albeit limited) Joomla Exception classes.
iirc many Joomla specific exception classes get removed lately ymmv
Not that I'm aware of? JException was removed, maybe the database exceptions since the Framework package is in use (which also has its own Exception subclasses), that's all I can think of off hand.
Not that I'm aware of? JException was removed, maybe the database exceptions since the Framework package is in use (which also has its own Exception subclasses), that's all I can think of off hand.
ok I thought there was more then the JException class.
There are 12 try-catch blocks in the joomla-cms repo right now. 9 of them are in the Crypto class, the other in Sniffs (phpcs). With this lack of precedence, I have low confidence that I can manage to write something that will be accepted.
I have tested this item
Tested unsuccessfully!
Exception doesn´t show up, when uploading file!
This pull request has automatically rebased to 4.2-dev.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-07-11 12:50:44 |
Closed_By | ⇒ | olleharstedt | |
Labels |
Added:
?
?
Removed: ? |
Two issues:
All exceptions have the same error code. If you want, I can make the error code different for each exception, making it possible for client code to react differently.
This change should be applied to ALL methods in the File class.