Closed tseaver closed 5 years ago
I don't think this is a problem that can be solved inzope.configuration
. It would be up to specific directives and fields to produce reasonable errors.
For attributes that aren't supported at all, toargs
already produces nice errors, for all levels of the directive tree:
zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "<string>", line 8.4-11.37
ConfigurationError: ('Unrecognized parameters:', 'biz')
The adapter
field specifies interfaces now and raises an error if misconfigured:
zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "<string>", line 6.2-6.79
ConfigurationError: ('Invalid value for', 'provides', "(<class '__main__.Foo'>, <InterfaceClass zope.interface.interfaces.IInterface>, '')")
(I will say that the original NotAnInterface
error is getting lost, which is a shame. But on Python 3, the chained tracebacks make this easier to deal with.)
If a particular directive is calling zope.component.provideAdapter
directly (which it shouldn't be anymore), it would be that directive's responsibility to provide a decent error or validation.
Via https://bugs.launchpad.net/zope.configuration/+bug/98257:
@philikon replied: