Error Reference

ChannelTypeError

Inherits: TypeError

Raised when a value sent to a channel does not match its type specification.

ch = Chan(int)
await ch.send("not_an_int")  # raises ChannelTypeError

Fields: expected, actual, channel_name

How to fix: Ensure the value matches the channel's type_spec. For Pydantic models, the dict must match the model's schema.

ChannelTopologyError

Raised when binding discipline is violated (e.g., binding a second writer).

ch = Chan(int)
ch.bind_writer("process_a")
ch.bind_writer("process_b")  # raises ChannelTopologyError

How to fix: Each channel allows at most one writer and one reader. Use unbind_writer() / unbind_reader() before rebinding, or create a new channel.

ChannelClosedError

Raised when sending to or receiving from a closed channel.

ch = Chan(int)
ch.close()
await ch.send(42)  # raises ChannelClosedError
await ch.recv()     # raises ChannelClosedError

How to fix: Check channel state before operations, or catch this exception to handle graceful shutdown in loops:

try:
    while True:
        value = await ch.recv()
        process(value)
except ChannelClosedError:
    pass  # channel was closed, stop processing

ChannelProtocolError

Raised when a SequentialProtocol's type sequence is exhausted.

ch = Chan(SequentialProtocol(str, int))
await ch.send("hello")
await ch.send(42)
await ch.send("extra")  # raises ChannelProtocolError

How to fix: Only send the exact number of values matching the protocol's type list.

AllGuardsDisabledError

Import: from stbass.alt import AllGuardsDisabledError

Raised when all guards in an ALT have static precondition=False.

await ALT(
    Guard(ch, precondition=False, handler=lambda v: v),
)  # raises AllGuardsDisabledError

How to fix: Ensure at least one guard has a true (or callable) precondition, or add a SKIP or TIMER fallback.

KeyError from ProcessContext

Raised when accessing a channel name that doesn't exist in the context.

ctx.get_channel("nonexistent")  # raises KeyError
await ctx.recv("nonexistent")   # raises KeyError

How to fix: Use ctx.channels to check available channels, or ensure your composition sets up the expected channels.