• Errors, Fallbacks, and Resilience

    index
    7
    status
    Draft

    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:

    1. If a fallback value is defined, it will be used.
    2. If no fallback is present, but a value is set, the system will fall back to value.
    3. If neither of these is available, the system will look for a min and max. If both are available, the value will be set to their mean. If only one of min or max are available, that will be used as the value.
    4. 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 inputs array for derived props — it’s required.
    • Use fallback if 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.