Skip to content

Collect error messages from failed conditions #733

@kopsha

Description

@kopsha

Currently, the may_<trigger>() methods return a simple boolean indicating whether a trigger is allowed given the current state and its conditions.

I wonder if it would be useful to allow collecting a list of messages about which conditions failed.

For example:

flow.may_install()  
# Returns: False  

# Proposed behavior:
flow.may_install(collect_fails=True)
# Returns:
[
    {"condition": "has_installation_report", "message": "Please upload an installation report first."},
]
# or maybe even the complete list of conditions
[
    {"condition": "has_installation_report", "result": False, "message": "Please upload an installation report first."},
    {"condition": "has_quality_approval", "result": True, "message": ""}
]

Benefits:

  • Provides actionable diagnostics for UI/UX or API feedback without raising exceptions.
  • Helps developers debug state machine failures more efficiently.
  • Keeps business logic (conditions) self-contained while making transitions introspectable.
  • Default behavior remains backward-compatible, returning a simple boolean.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions