You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our validation code using zope.schema fields, we have lots of things that look like this:
try:
field.validate(value)
exceptWrongContainedTypease:
ife.argsandall(isinstance(SchemaNotProvided, v) forvine.args[0]):
# try to adaptexceptWrongTypease:
iflen(e.args) ==3:
expected_type=e.args[1]
# try to adaptexceptTooLongase:
iflen(e.args) ==2:
max_size=e.args[1]
# Produce a pretty error message
All this argument parsing feels fragile.
With named attributes, we could document what exceptions are expected to have. We could use keyword arguments (with defaults) in the constructors to maintain compatibility with code that raises bare exceptions or uses different arguments.
The text was updated successfully, but these errors were encountered:
In our validation code using zope.schema fields, we have lots of things that look like this:
All this argument parsing feels fragile.
With named attributes, we could document what exceptions are expected to have. We could use keyword arguments (with defaults) in the constructors to maintain compatibility with code that raises bare exceptions or uses different arguments.
The text was updated successfully, but these errors were encountered: