Messag...orChain(3pm)
π Messag...orChain(3pm) β bestie edition π
okay so this is a page from the User Contributed Perl Documentation, and the header on it is literally Messag...orChain(3pm) because somebody's terminal was NOT about to fit the whole name in there. iconic behaviour honestly. anyway, sit down, grab a strawberry π, we're learning about error chains.
β¨ NAME β¨
Message::Passing::Role::HasErrorChain β it's a role for components which can report errors. that's it, that's the whole vibe. a role that lets your component have opinions about things going wrong π
π¦ SYNOPSIS π¦
so here's how you'd actually use it. note the little disclaimer at the top because we do NOT want you out here looking for a package that doesn't exist:
# Note this is an example package, and does not really exist!
package Message::Passing::Output::ErrorAllMessages;
use Moo;
use namespace::clean -except => 'meta';
with qw/
Message::Passing::Role::Output
Message::Passing::Role::HasErrorChain
/;
sub consume {
my ($self, $message) = @_;
$self->error->consume($message);
}
see how it with-es in both Message::Passing::Role::Output and Message::Passing::Role::HasErrorChain? then consume just shoves the message straight into $self->error. no cap, that's the entire move. π
πΈ DESCRIPTION πΈ
some components are β¨specialβ¨ and can create an error stream on top of their regular message stream. like, they're doing the normal thing, but they also have a whole separate lane for when stuff goes sideways. main character energy, honestly.
π METHODS π
π error
an attribute containing the error chain.
by default, this is a chain of:
Message::Passing::Filter::Encoder::JSONMessage::Passing::Output::STDOUT
so out of the box your errors get JSON-encoded and then yeeted to STDOUT. simple, clean, slay. π
π WARNINGS π
bestie. listen to this section. i am not joking around here. π
π ERROR CHAINS CAN LOOP
if you override the error chain output, be sure that the error chain does not go into your normal log path!
here's the whole cursed cycle, spelled out: if you suddenly have errors in your normal log path, and you then start logging these errors, this causes more errors β causing you to generate a message loop. it's giving snake eating its own tail. it's giving ouroboros but make it logging. do not do this. π
π€ ENCODING IN ERROR CHAINS
if you emit something which cannot be encoded to an error chain, then the encoding error will likely be emitted by the error chain β this can again cause loops and other issues. yeah. the error about the error becomes an error. we love a recursive meltdown fr fr. π
all components which use error chains should be very careful to output data which they are entirely certain will be able to be encoded. like, be so sure. be more sure than that. be certain certain. π«Ά
π SPONSORSHIP π
this module exists because of the wonderful people at Suretec Systems Ltd. <http://www.suretecsystems.com/> β they sponsored its development for their VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with the SureVoIP API β <http://www.surevoip.co.uk/support/wiki/api_documentation>
shoutout to the sponsors, we love a patron of the arts πβ¨
π AUTHOR, COPYRIGHT AND LICENSE π
see Message::Passing. (yes that's the whole thing. short and sweet, just like this section. go read that one, iykyk π)
and that's the page!! this was built against perl v5.32.1 and the whole thing is dated 2021-11-09, from the User Contributed Perl Documentation. mwah, take care of your error chains, don't loop them, and go be the most well-behaved logging component you can be. periodt. π
β¨π¦
π¦ where this page comes from
- debian bookworm: libmessage-passing-perl 0.117-1 Β· LGPL-2.1-only
- debian trixie: libmessage-passing-perl 0.117-1 Β· LGPL-2.1-only
- ubuntu jammy: libmessage-passing-perl 0.117-1 Β· LGPL-2.1-only
- ubuntu noble: libmessage-passing-perl 0.117-1 Β· LGPL-2.1-only
- ubuntu resolute: libmessage-passing-perl 0.117-1 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms