correspond.errors#
What correspond raises, and the vocabulary a failed write reports.
Two families, on purpose:
Mistakes a caller fixes in code or configuration raise: an unknown channel (
UnknownChannel), a malformed conversation reference (InvalidRef), an operation the channel does not have (NotSupported). A retry changes nothing.Failures of the platform or of the message are
ChannelErrorinside an adapter, carrying ankindfromERROR_KINDS,retryableandretry_after. Reads let them propagate; the write verbs turn them into aSendResultwithok=False, so a notifier never crashes its caller.
A third family stops a write before it leaves: the before_send check (see
correspond.outbound) raises Refused or NeedsApproval, and the write
verbs report it as a SendResult whose error_kind is one of CHECK_KINDS.
>>> str(NotSupported("react", "ntfy"))
'ntfy does not support react'
>>> error = ChannelError("slow down", kind="rate_limited", retryable=True, retry_after=30)
>>> error.kind, error.retryable, error.retry_after
('rate_limited', True, 30.0)
>>> held = NeedsApproval("public audience")
>>> held.error_kind, held.reason
('needs_approval', 'public audience')
Module Attributes
Why a platform call failed, for a caller deciding whether to retry, fix the draft, or ask a human. |
|
Why the |
Exceptions
|
The |
|
The configured |
|
A platform call that failed, classified so the caller can decide what to do. |
An expected failure, with a message meant for the person or agent that asked. |
|
A conversation reference that does not parse, or that its channel rejects. |
|
|
Something the channel needs is not here: a credential, a binary, an extra, an OS. |
|
Draft to operator: the write waits for the operator's approval. |
|
The channel does not have this operation (or this feature of it). |
|
Block: this draft does not go to this conversation as written. |
|
A write the |
|
A channel name that no registered adapter answers to. |
- exception correspond.errors.BeforeSendFailed(reason, **details)[source]#
Bases:
StoppedThe
before_sendcheck raised something else, or returned a value, so nothing is sent.
Bases:
StoppedThe configured
before_sendcheck could not be loaded, so nothing is sent.
- correspond.errors.CHECK_KINDS = ('refused', 'needs_approval', 'before_send_unavailable', 'before_send_failed')#
Why the
before_sendcheck stopped a write. Nothing was sent; a retry of the same draft changes nothing.
- exception correspond.errors.ChannelError(message, *, kind, retryable=False, retry_after=None)[source]#
Bases:
CorrespondErrorA platform call that failed, classified so the caller can decide what to do.
- exception correspond.errors.CorrespondError[source]#
Bases:
ExceptionAn expected failure, with a message meant for the person or agent that asked.
- correspond.errors.ERROR_KINDS = ('auth', 'permission', 'not_found', 'rate_limited', 'network', 'validation', 'unavailable', 'unconfirmed')#
Why a platform call failed, for a caller deciding whether to retry, fix the draft, or ask a human.
- exception correspond.errors.InvalidRef[source]#
Bases:
CorrespondError,ValueErrorA conversation reference that does not parse, or that its channel rejects.
- exception correspond.errors.MissingRequirement(channel, missing, *, fix, kind='unavailable')[source]#
Bases:
ChannelErrorSomething the channel needs is not here: a credential, a binary, an extra, an OS.
- exception correspond.errors.NeedsApproval(reason, **details)[source]#
Bases:
StoppedDraft to operator: the write waits for the operator’s approval. Raised by a
before_sendcheck.
- exception correspond.errors.NotSupported(operation, channel, *, alternatives=())[source]#
Bases:
CorrespondErrorThe channel does not have this operation (or this feature of it). Never a silent no-op.
- exception correspond.errors.Refused(reason, **details)[source]#
Bases:
StoppedBlock: this draft does not go to this conversation as written. Raised by a
before_sendcheck.
- exception correspond.errors.Stopped(reason, **details)[source]#
Bases:
CorrespondErrorA write the
before_sendcheck did not let leave:error_kindsays how,reasonsays why.Keyword
details(an approval id, a draft hash) travel with the result, in the plan’sbefore_send_details.
- exception correspond.errors.UnknownChannel(channel, *, known=(), hint='')[source]#
Bases:
CorrespondError,LookupErrorA channel name that no registered adapter answers to.