Description
When a user passes the wrong type to Config, the error message is misleading.
The problem
Config(storage="not a storage")
# NotCallableObject: Problem validating the 'storage' object type; this is not a callable object
The message says "not a callable object" but the real problem is "wrong type". The user thinks: "but I didn't try to call anything?"
The fix
A clearer message:
# Before
"Problem validating the 'storage' object type; this is not a callable object"
# After
"'storage' must be an instance of Storage, got str instead"
How to implement
-
In dotflow/core/exception.py — update NotCallableObject message or create a new InvalidProviderType exception:
class InvalidProviderType(DotFlowException):
def __init__(self, name: str, expected: type, got: type):
super().__init__(f"'{name}' must be an instance of {expected.__name__}, got {got.__name__} instead")
-
In dotflow/core/config.py — update the _validate() call:
if value is not None and not isinstance(value, abc):
raise InvalidProviderType(name=name, expected=abc, got=type(value))
-
Small change in 2 files, improves error UX for all users
Description
When a user passes the wrong type to
Config, the error message is misleading.The problem
The message says "not a callable object" but the real problem is "wrong type". The user thinks: "but I didn't try to call anything?"
The fix
A clearer message:
How to implement
In
dotflow/core/exception.py— updateNotCallableObjectmessage or create a newInvalidProviderTypeexception:In
dotflow/core/config.py— update the_validate()call:Small change in 2 files, improves error UX for all users