.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.13) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' '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 turned on, 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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" ======================================================================== .\" .IX Title "Locale::Intl::Exception 3" .TH Locale::Intl::Exception 3 "2024-10-06" "perl v5.10.1" "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 "NAME" Locale::Intl::Exception \- Locale International Exception Class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 9 \& my $ex = Locale::Intl::Exception\->new({ \& code => 400, \& type => $error_type, \& file => \*(Aq/home/joe/some/lib/My/Module.pm\*(Aq, \& line => 120, \& message => \*(AqInvalid property provided\*(Aq, \& package => \*(AqMy::Module\*(Aq, \& subroutine => \*(Aqcustomer_info\*(Aq, \& }); .Ve .PP or, providing a list of string that will be concatenated: .PP .Vb 1 \& my $ex = Locale::Intl::Exception\->new( "Some error", "has occurred:", $details ); .Ve .SH "VERSION" .IX Header "VERSION" .Vb 1 \& v0.1.0 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is an exception class for Locale::Intl .PP When stringified, it provides the error message along with precise information about where the error occurred. .PP Locale::Intl::Exception objects are created by \*(L"error\*(R" in Locale::Intl method. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" It takes either an Locale::Intl::Exception object or an hash reference of properties, or a list of arguments that will be concatanated to form the error message. The list of arguments can contain code reference such as reference to sub routines, who will be called and their returned value added to the error message string. For example : .PP .Vb 1 \& my $ex = Locale::Intl::Exception\->new( "Invalid property. Value received are: ", sub{ Dumper( $hash ) } ); \& \& # or \& \& my #ex = Locale::Intl::Exception\->new({ \& message => "Invalid property.", \& code => 400, \& type => \*(Aqcustomer\*(Aq, \& }) .Ve .PP Possible properties that can be specified are: .IP "\(bu" 4 \&\f(CW\*(C`code\*(C'\fR .Sp An error code .IP "\(bu" 4 \&\f(CW\*(C`file\*(C'\fR .Sp The location where the error occurred. .IP "\(bu" 4 \&\f(CW\*(C`line\*(C'\fR .Sp The line number in the file where the error occurred. .IP "\(bu" 4 \&\f(CW\*(C`message\*(C'\fR .Sp The error message. It can be provided as a list of arguments that will be concatenated, or as the \fImessage\fR property in an hash reference, or copied from another exception object passed as the sole argument. .IP "\(bu" 4 \&\f(CW\*(C`package\*(C'\fR .Sp The package name where the error occurred. .IP "\(bu" 4 \&\f(CW\*(C`retry_after\*(C'\fR .Sp An optional value to indicate in seconds how long to wait to retry. .IP "\(bu" 4 \&\f(CW\*(C`skip_frames\*(C'\fR .Sp This is used as a parameter to caller upon instantiation to instruct how many it should skip to start getting key values. .IP "\(bu" 4 \&\f(CW\*(C`type\*(C'\fR .Sp An optional error type .PP It returns the exception object. .SS "as_string" .IX Subsection "as_string" This returns a string representation of the Exception such as : .PP .Vb 1 \& Invalid property within package My::Module at line 120 in file /home/john/lib/My/Module.pm .Ve .SS "code" .IX Subsection "code" Set or get the error code. It returns the current value. .SS "file" .IX Subsection "file" Set or get the file path where the error originated. It returns the current value. .SS "line" .IX Subsection "line" Set or get the line where the error originated. It returns the current value. .SS "message" .IX Subsection "message" Set or get the error message. It returns the current value. .PP It takes a string, or a list of strings which will be concatenated. .PP For example : .PP .Vb 1 \& $ex\->messsage( "I found some error:", $some_data ); .Ve .SS "package" .IX Subsection "package" Set or get the class/package name where the error originated. It returns the current value. .SS "\s-1PROPAGATE\s0" .IX Subsection "PROPAGATE" This method is called by perl when you call \*(L"die\*(R" in perlfunc with no parameters and \f(CW$@\fR is set to a Locale::Intl::Exception object. .PP This returns a new exception object that perl will use to replace the value in \f(CW$@\fR .SS "rethrow" .IX Subsection "rethrow" This rethrow (i.e. \*(L"die\*(R" in perlfunc) the original error. It must be called with the exception object or else it will return undef. .PP This is ok : .PP .Vb 1 \& $ex\->rethrow; .Ve .PP But this is not : .PP .Vb 1 \& Locale::Intl::Exception\->rethrow; .Ve .SS "retry_after" .IX Subsection "retry_after" Set or get the number of seconds to way before to retry whatever cause the error. It returns the current value. .SS "throw" .IX Subsection "throw" Provided with a message string, this will create a new Locale::Intl::Exception object and call \*(L"die\*(R" in perlfunc with it. .SS "\s-1TO_JSON\s0" .IX Subsection "TO_JSON" Special method called by \s-1JSON\s0 to transform this object into a string suitable to be added in a json data. .SS "type" .IX Subsection "type" Set or get the error type. It returns the current value. .SH "SERIALISATION" .IX Header "SERIALISATION" Serialisation by \s-1CBOR\s0, Sereal and Storable::Improved (or the legacy Storable) is supported by this package. To that effect, the following subroutines are implemented: \f(CW\*(C`FREEZE\*(C'\fR, \f(CW\*(C`THAW\*(C'\fR, \f(CW\*(C`STORABLE_freeze\*(C'\fR and \f(CW\*(C`STORABLE_thaw\*(C'\fR .SH "AUTHOR" .IX Header "AUTHOR" Jacques Deguest <\fIjack@deguest.jp\fR> .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright (c) 2024 \s-1DEGUEST\s0 Pte. Ltd. .PP You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.