Find a way to prevent having to check FAILURE after every action #7
Replies: 1 comment
-
|
While thinking through this, I found some possible solutions. One approach is to create a decorator that automatically creates "unsafe" variants of each function. These unsafe functions, instead of returning We could very easily make a function say: def generate_unsafe[**P, R](
exception_type: type[Exception] = OperationFailedError, error_message: str | None = None
) -> Callable[[Callable[P, R]], Callable[P, R]]:That would automatically create an "unsafe" version of the function, e.g., world.get_component_unsafe() # Should we use this naming scheme? It's technically not unsafe, just errors.
world.get_component_or_raise() # Is this too long of a name?I prefer the latter ( Let us at least start with this approach of unsafe generation, but then we can deprecate and slate for removal later on in development when we have a more sound understanding of our architecture. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions