Throwable(3)
okay so this is Throwable(3) from the User Contributed Perl Documentation, and if you're here bestie, it's giving βI am making exception objects and I want them to be cute and throwable.β valid. let's go π
β¨ NAME β¨
Throwable β a role for classes that can be thrown. that's it, that's the name section, no cap π
πΈ VERSION πΈ
version 1.001 β yes bestie, that's the version. periodt β¨
π¦ SYNOPSIS π¦
here's the vibe:
package Redirect;
# NOTE: Moo can also be used here instead of Moose
use Moose;
with 'Throwable';
has url => (is => 'ro');
then later, literally:
Redirect->throw({ url => $url });
π DESCRIPTION π
Throwable is a role for classes that are meant to be thrown as exceptions to standard program flow. it is very simple and does only two things: saves any previous value for $@ and calls die $self. iconic, lowkey minimal, obsessed.
Throwable is implemented with Moo, so you can stick to Moo or use Moose, as you prefer. choose your fighter π«Ά
π PERL VERSION π
this library should run on perls released even a long time ago. it should work on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl. so like, the floor can move, bestie β that's the caveat π
π ATTRIBUTES π
previous_exception
This attribute is created automatically, and stores the value of $@ when the Throwable object is created. This is done on a best effort basis.
$@ is subject to lots of spooky action-at-a-distance. For now, there are clearly ways that the previous exception could be lost. bestie, it's best effort, not a blood oath π
π METHODS π
throw
Something::Throwable->throw({ attr => $value });
This method will call new, passing all arguments along to new, and will then use the created object as the only argument to die.
If called on an object that does Throwable, the object will be rethrown. slay, it knows how to rethrow itself π
new_with_previous
die Something::Throwable->new_with_previous({ attr => $value });
Constructs an exception object and returns it, while trying to make sure that any values in $@ are safely stored in previous_exception without being stomped by evals in the construction process.
This is more reliable than calling new directly, but doesn't include the forced die in throw. so like, it protects the previous exception vibe but does not do the dramatic exit itself π
π AUTHORS π
Ricardo SIGNES <cpan@semiotic.systems>β author, absolute legendFlorian Ragwitz <rafl@debian.org>β author, also iconic
π CONTRIBUTORS π
Arthur Axel 'fREW' Schmidt <frioux@gmail.com>β contributorBrian Manning <brian@xaoc.org>β contributorBrian Manning <xaoc@cpan.org>β contributorChristian Walde <walde.christian@googlemail.com>β contributorDagfinn Ilmari MannsΓ₯ker <ilmari@ilmari.org>β contributorDave Rolsky <autarch@urth.org>β contributorDavid E. Wheeler <david@justatheory.com>β contributorGraham Knop <haarg@haarg.org>β contributorJeffrey Ryan Thalhammer <jeff@imaginative-software.com>β contributorJustin Hunter <justin.d.hunter@gmail.com>β contributorMatt S Trout <mst@shadowcat.co.uk>β contributorOlaf Alders <olaf@wundersolutions.com>β contributorRicardo Signes <rjbs@semiotic.systems>β contributorToby Inkster <mail@tobyinkster.co.uk>β contributor
all of them ate, fr fr π«Ά
π«Ά COPYRIGHT AND LICENSE π«Ά
This software is copyright (c) 2022 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
k that's the whole page, bestie π
β it's from perl v5.42.0, dated 2023-01-03, and the manual is Throwable(3). mwah π«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Throwable 1.001-bp160.1.12 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms