Problem/Motivation
Currently, when a plugin cannot be found, we get this obtuse error message:
Drupal\Component\Plugin\Exception\PluginException: The plugin (%plugin) did not specify an instance class in Drupal\Component\Plugin\Factory\DefaultFactory->getPluginClass() (line 60 of /path/to/webroot/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php).
first, this is incorrect - what's usually happening is that no plugin definition was found, not that the found plugin definition did not specify an instance class. second, it gives us very little useful information about WHICH plugin actually failed - we just have the plugin id, not the owner/type information. that's a little tricky to get at.
Proposed resolution
introduce new exceptions - PluginNotFoundException
and DerivativeNotFoundException
- that can be thrown by the various Discovery implementations when plugins aren't actually found.
Remaining tasks
the exceptions still don't include contextual information about the plugin type when throwing exceptions. we could probably expand the DiscoveryInterface
to include such contextual information purely for the purpose of these exceptions.
API changes
any new Discovery classes, decorators, etc., should follow the practice of throwing the appropriate exception for their case.