xtr_notifier.exception ¶
The errors the notifier raises, every one a :class:NotifierError.
IncompleteDsnError ¶
Bases: InvalidArgumentError
A DSN parses, but lacks a part its transport cannot work without — a token, a user.
Attributes:
-
original_dsn(str | None) –The DSN the part is missing from, as the caller chose to show it, or
None. Pass a form without credentials: the message names it.
Say what is missing, and from which DSN.
Parameters:
-
message(str) –What is missing.
-
dsn(str | None, default:None) –The DSN it is missing from, prefixed to the message when given. Never the raw DSN when it carries credentials.
InvalidArgumentError ¶
Bases: NotifierError, ValueError
A value handed to this library cannot be used: a malformed DSN, an empty phone number.
Also a :class:ValueError, so code that already guards against a bad value
catches it without knowing this library exists.
LengthError ¶
Bases: LogicError
A value is longer than the provider it is going to accepts — a subject, a button label.
A logic error rather than a runtime one: the same value fails the same way every time, so it is fixed where the message is built, not retried.
LogicError ¶
Bases: NotifierError, RuntimeError
This library was used in a way that cannot work, whatever the message carries.
A message no configured transport supports, a transport handed a message type it was never built for: each is a mistake in the code or the configuration, so retrying it changes nothing.
MissingRequiredOptionError ¶
Bases: IncompleteDsnError
A DSN leaves out, or leaves blank, a query option its transport requires.
Attributes:
-
option(str) –The option that is missing.
Name the missing option.
Parameters:
-
option(str) –The option that is missing.
-
dsn(str | None, default:None) –The DSN it is missing from, without credentials, when known.
MultipleExclusiveOptionsUsedError ¶
MultipleExclusiveOptionsUsedError(used_exclusive_options: Sequence[str], exclusive_options: Sequence[str])
Bases: InvalidArgumentError
Options that each pick what a message is — a photo, a location — were set together.
Attributes:
-
used_exclusive_options(tuple[str, ...]) –The exclusive options that were set.
-
exclusive_options(tuple[str, ...]) –Every option only one of which may be set.
Name the clashing options and the set they belong to.
Parameters:
-
used_exclusive_options(Sequence[str]) –The exclusive options that were set.
-
exclusive_options(Sequence[str]) –Every option only one of which may be set.
NotifierError ¶
Bases: Exception
Something a notification could not be sent through — catch this to catch them all.
NotifierRuntimeError ¶
Bases: NotifierError, RuntimeError
Something a notification depends on failed while it was sent — every transport, say.
The input was fine and the code is fine; the world did not cooperate. Raising one out of a message handler is what makes a message bus retry the send.
TransportError ¶
Bases: NotifierRuntimeError
A provider could not be reached, or answered a message with a refusal.
It is the one error a round-robin or failover transport takes as a sign that a transport is down: anything else is a mistake that another transport would make too. It carries the response, so a caller can read what the provider said, and the client's debug trace of the transfer, when it kept one. A provider that could not be reached gave no response: the client raised instead, and that error is the cause of this one.
Attributes:
-
response(HttpResponseInterface | None) –What the provider answered with, or
Nonewhen it never answered. -
debug(str) –The transfer's
debuginfo, or""when the client kept none.
Record why the send failed and what the provider answered.
Parameters:
-
message(str) –Why the send failed, in the provider's words where it gave any.
-
response(HttpResponseInterface | None, default:None) –What the provider answered with;
Nonewhen it never answered.
UnsupportedMessageTypeError ¶
Bases: LogicError
A transport was handed a message of a type it does not send — an SMS to a chat provider.
Attributes:
-
transport(str) –The transport that refused the message.
-
supported(str) –The message type it sends.
-
given(str) –The name of the type it was handed.
Name the transport, what it sends and what it was handed.
Parameters:
-
transport(str) –The transport that refused the message.
-
supported(str) –The message type it sends.
-
given(object) –The message it was handed; only its type is reported.
UnsupportedOptionsError ¶
Bases: LogicError
A transport was handed options another provider's builder rendered.
Attributes:
-
transport(str) –The transport that refused the options.
-
supported(str) –The kind of options it reads.
-
given(str) –What it was handed instead.
Name the transport, the options it reads and what it was handed.
Parameters:
-
transport(str) –The transport that refused the options.
-
supported(str) –The kind of options it reads.
-
given(str) –The kind of options it was handed.
UnsupportedSchemeError ¶
Bases: LogicError
No factory serves a DSN's scheme.
The common cause is a provider library that is not installed, so a scheme a first-party provider library serves is answered with the command that installs it. Any other scheme is answered with the schemes that are supported, when the caller knows them. The message names the scheme only: never the DSN, which carries credentials.
Attributes:
-
scheme(str) –The scheme no factory serves.
-
name(str | None) –What was looking for a factory —
"chatter","texter"— orNone. -
supported(tuple[str, ...]) –The schemes that are supported there.
Explain why scheme has no transport.
Takes the scheme rather than the DSN, so nothing that carries credentials ever reaches an error.
Parameters:
-
scheme(str) –The scheme of the DSN no factory serves.
-
name(str | None, default:None) –What was looking for a factory, named in the message with
supported. -
supported(Sequence[str], default:()) –The schemes that are supported there.