.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.48) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "Throwable 3" .TH Throwable 3 2026-10-26 "perl v5.44.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 4 \& package Redirect; \& # NOTE: Moo can also be used here instead of Moose \& use Moose; \& with \*(AqThrowable\*(Aq; \& \& has url => (is => \*(Aqro\*(Aq); .Ve .PP \&...then later... .PP .Vb 1 \& Redirect\->throw({ url => $url }); .Ve .SH DESCRIPTION .IX Header "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 \f(CW$@\fR and calls \f(CW\*(C`die $self\*(C'\fR. .PP Throwable is implemented with Moo, so you can stick to Moo or use Moose, as you prefer. .PP This attribute is created automatically, and stores the value of \f(CW$@\fR when the Throwable object is created. This is done on a \fIbest effort basis\fR. \f(CW$@\fR is subject to lots of spooky action\-at\-a\-distance. For now, there are clearly ways that the previous exception could be lost. .PP .Vb 1 \& Something::Throwable\->throw({ attr => $value }); .Ve .PP This method will call new, passing all arguments along to new, and will then use the created object as the only argument to \f(CW\*(C`die\*(C'\fR. .PP If called on an object that does Throwable, the object will be rethrown. .PP .Vb 1 \& die Something::Throwable\->new_with_previous({ attr => $value }); .Ve .PP Constructs an exception object and return it, while trying to make sure that any values in $@ are safely stored in \f(CW\*(C`previous_exception\*(C'\fR without being stomped by evals in the construction process. .PP This is more reliable than calling \f(CW\*(C`new\*(C'\fR directly, but doesn\*(Aqt include the forced \f(CW\*(C`die\*(C'\fR in \f(CW\*(C`throw\*(C'\fR. .SH "POD ERRORS" .IX Header "POD ERRORS" Hey! \fBThe above document had some coding errors, which are explained below:\fR .IP "Around line 31:" 4 .IX Item "Around line 31:" Unknown directive: =attr .IP "Around line 55:" 4 .IX Item "Around line 55:" Unknown directive: =method .IP "Around line 79:" 4 .IX Item "Around line 79:" Unknown directive: =method