Typo3ExtensionUtils
Typo3ExtensionUtils copied to clipboard
Extract does not offer correct return value on Exception
Using "t3xutils.phar extract", the exit code is always 0, even if there was an exception.
The exit code is determined by $success when Dispatcher exits here: https://github.com/etobi/Typo3ExtensionUtils/blob/master/lib/etobi/extensionUtils/Dispatcher.php#L91
$status is supposed to be set in extractCommand with the return value of extractAction: https://github.com/etobi/Typo3ExtensionUtils/blob/master/lib/etobi/extensionUtils/Dispatcher.php#L216
But, extractAction does not have a return value: https://github.com/etobi/Typo3ExtensionUtils/blob/master/lib/etobi/extensionUtils/Controller/T3xController.php#L73
Also, the exception catcher does not exit with any error codes: https://github.com/etobi/Typo3ExtensionUtils/blob/master/bin/t3xutils.php#L14
Either the extractAction needs to somehow return an appropriate boolean, or the exception catcher needs to exit with an error code.
As you already digged into this: could you provide a patch/PR?
Which solution would you prefer? Does the exit line here ever return any error codes (should the fix focus on this)? https://github.com/etobi/Typo3ExtensionUtils/blob/master/lib/etobi/extensionUtils/Dispatcher.php#L91
Or should I focus on catching exceptions here: https://github.com/etobi/Typo3ExtensionUtils/blob/master/bin/t3xutils.php#L14
i guess catching the exception and returning the correct exit code there might be the "right" way. All actions throw exceptions, if they don't succeed.
However, to not confuse the next developer looking at https://github.com/etobi/Typo3ExtensionUtils/blob/master/lib/etobi/extensionUtils/Dispatcher.php#L91 this should be cleaned up, too.
I just double checked the actions. Seems like some actions do return TRUE/FALSE (like https://github.com/etobi/Typo3ExtensionUtils/blob/master/lib/etobi/extensionUtils/Controller/TerController.php#L125).
I like to suggest to streamline the error handling (always throw an exception, instead of returning TRUE/FALSE) in all actions, implementing an "own Exception" (e.g. ActionFailedException extends \Exception) and catch that in the Dispatcher or t3xutils.php
What do you think?
That could work. It'll be awhile before I can dig into this again.