Errors, Fallbacks, and Resilience
Workbench is designed to be resilient in the face of authoring or runtime errors, especially when it comes to derived props. This section outlines how errors are handled and how authors can write more robust configurations.
Derived prop errors
If a derived prop’s derive function throws an error — whether due to a bug or unexpected inputs — Workbench will fail gracefully. Instead of crashing, it attempts a fallback strategy.
Fallback behavior
When a derived prop fails to evaluate:
- If a
fallbackvalue is defined, it will be used. - If no
fallbackis present, but avalueis set, the system will fall back tovalue. - If neither of these is available, the system will look for a
minandmax. If both are available, thevaluewill be set to their mean. If only one ofminormaxare available, that will be used as thevalue. - If all else fails, the prop will be set to
undefined.
This ensures that a single broken function won’t take down the entire workbench.
Errors are logged in development mode to aid debugging, but fail silently in production.
Dependency constraints
Derived props can depend on any other props — including other derived props — as long as those dependencies are declared explicitly using the inputs array. Workbench resolves derived props in topological order to ensure that each derivation has access to up-to-date values for its dependencies.
This allows for complex transformation chains, while still preventing circular dependencies. If a circular dependency is detected, an error will be logged and affected props will fall back to their fallback or value, if provided.
Best practices
- Always specify an
inputsarray for derived props — it’s required. - Use
fallbackif your derivation function might encounter edge cases or divisions by zero. - Keep derive functions pure and side-effect-free.
- Prefer simple, predictable transformations for maximum clarity and stability.