\Drupal\Core\Entity\EntityTypeManagerInterface::getStorage() documents (without description text) that it might throw \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException. Actually, though, it can also throw \Drupal\Component\Plugin\Exception\PluginNotFoundException, namely if the entity type doesn't even exist.
Code to test:
try {
\Drupal::entityTypeManager()->getStorage('foo');
}
catch (\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException $e) {}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2899051-2--getStorage_throws_docs.patch | 780 bytes | drunken monkey |
Comments
Comment #2
drunken monkeyThis would fix the docs.
Alternately, we could also document that the method can throw
\Drupal\Component\Plugin\Exception\PluginException, which is the parent of both other exceptions.Comment #5
borisson_This patch still applies, but I don't see where
PluginNotFoundExceptionis thrown from.Comment #6
drunken monkeyThanks for reviewing!
Comment #7
borisson_Thanks for explaining, looks great!
Comment #8
alexpottCommitted and pushed 64fbabd716 to 8.6.x and 6f911f61dc to 8.5.x. Thanks!
As this is a docs only improvement backported to 8.5.x.