Problem/Motivation
KernelTestBase::installConfig($modules) can be called with a list of modules, but if one of them causes a failure, you don't know which one it was.
A simple improvement would be to catch any exceptions and re-throw them with a message to say which module caused the problem, like this:
try {
$this->container->get('config.installer')->installDefaultConfig('module', $module);
}
catch (\Exception $e) {
throw new \Exception(sprintf('Exception when installing config for module %s, message was: %s', $module, $e->getMessage()), 0, $e);
}
(tagging as Novice, if someone wants to make an MR from the above code before I get round to it)
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 3308162-13.patch | 877 bytes | immaculatexavier |
| #10 | 3308162-10.patch | 982 bytes | immaculatexavier |
| #7 | 3308162-7.patch | 1.21 KB | chaubeyji |
| #7 | 3308162-7.patch | 1.21 KB | chaubeyji |
| #5 | interdiff_4-5.txt | 1.08 KB | immaculatexavier |
Comments
Comment #2
chaubeyji commentedI have created a patch as you suggested, please review.
Comment #3
joachim commentedThanks!
Not quite right though:
This exception needs to be kept.
Comment #4
immaculatexavier commentedFixed the custom commands against #2
Comment #5
immaculatexavier commented@jaochim,
Attached patch against #3
Comment #6
joachim commentedThis patch is making tons of other changes!
Comment #7
chaubeyji commentedPlease try now.
Comment #8
joachim commentedNo, this is messing with the earlier exception.
Comment #9
joachim commentedThe only change that is needed is wrapping the call to installDefaultConfig in a try/catch block.
Comment #10
immaculatexavier commentedI made a patch earlier against #2.
I have now built a patch from the ground up.
Also for a note:
When we add exception below if condition an error throw as below
-------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-------------------------------------------------------------------
703 | WARNING | Code after the THROW statement on line 702 cannot be executed
704 | WARNING | Code after the THROW statement on line 702 cannot be executed
706 | WARNING | Code after the THROW statement on line 702 cannot be executed
707 | WARNING | Code after the THROW statement on line 702 cannot be executed
So i have removed THROW statement on line 702
Kindly review.
Comment #11
joachim commentedThis is the same problem as the earlier patch -- the exception thrown when the module isn't enabled has been removed!
Comment #12
catchIt's this line that should be replaced with the try/catch that's added in the patch.
Comment #13
immaculatexavier commented@joachim , sorry for the misplacement.
@catch, thanks for the resolution.
Attached patch against #12
Comment #14
joachim commentedPerfect, thanks!
Comment #15
alexpottCommitted and pushed cc7f697733 to 10.1.x and a99518b374 to 10.0.x and 93c1a95d57 to 9.5.x. Thanks!
Backported to 9.5.x as this is a test-only improvement with no BC issues.