NAME
Locale::Unicode::RBNF::Exception - Locale Unicode Data Exception Class
SYNOPSIS
my $ex = Locale::Unicode::RBNF::Exception->new({
code => 400,
type => $error_type,
file => '/home/joe/some/lib/My/Module.pm',
line => 120,
message => 'Invalid property provided',
package => 'My::Module',
subroutine => 'customer_info',
});
my $e = Locale::Unicode::RBNF::Exception->new( 'Some message' );
my $e = Locale::Unicode::RBNF::Exception->new({ message => 'Some message', code => 500, skip_frames => 1 });
or, providing a list of string that will be concatenated:
my $ex = Locale::Unicode::RBNF::Exception->new( "Some error", "has occurred:", $details );
VERSION
v0.1.0
DESCRIPTION
This is an exception class for Locale::Unicode::RBNF
When stringified, it provides the error message along with precise information about where the error occurred.
Locale::Unicode::RBNF::Exception objects are created by "error" in Locale::Unicode::RBNF method.
METHODS
new
It takes either an Locale::Unicode::RBNF::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 :
my $ex = Locale::Unicode::RBNF::Exception->new( "Invalid property. Value recieved are: ", sub{ Dumper( $hash ) } );
# or
my #ex = Locale::Unicode::RBNF::Exception->new({
message => "Invalid property.",
code => 400,
type => 'customer',
})
Possible properties that can be specified are:
codeAn error code
fileThe location where the error occurred.
lineThe line number in the file where the error occurred.
messageThe error message. It can be provided as a list of arguments that will be concatenated, or as the message property in an hash reference, or copied from another exception object passed as the sole argument.
packageThe package name where the error occurred.
retry_afterAn optional value to indicate in seconds how long to wait to retry.
skip_framesThis is used as a parameter to caller upon instantiation to instruct how many it should skip to start getting key values.
typeAn optional error type
It returns the exception object.
as_string
This returns a string representation of the Exception such as :
Invalid property within package My::Module at line 120 in file /home/john/lib/My/Module.pm
clone
This returns a cloned copy of the exception.
It is used by the special PROPAGATE method called by Perl's die
code
Set or get the error code. It returns the current value.
file
Set or get the file path where the error originated. It returns the current value.
line
Set or get the line where the error originated. It returns the current value.
message
Set or get the error message. It returns the current value.
It takes a string, or a list of strings which will be concatenated.
For example :
$ex->messsage( "I found some error:", $some_data );
package
Set or get the class/package name where the error originated. It returns the current value.
PROPAGATE
This method is called by perl when you call "die" in perlfunc with no parameters and $@ is set to a Locale::Unicode::RBNF::Exception object.
This returns a new exception object that perl will use to replace the value in $@
reset
Marks the current instance as outdated when a method is accessed in mutator mode.
rethrow
This rethrow (i.e. "die" in perlfunc) the original error. It must be called with the exception object or else it will return undef.
This is ok :
$ex->rethrow;
But this is not :
Locale::Unicode::RBNF::Exception->rethrow;
retry_after
Set or get the number of seconds to way before to retry whatever cause the error. It returns the current value.
throw
Provided with a message string, this will create a new Locale::Unicode::RBNF::Exception object and call "die" in perlfunc with it.
TO_JSON
Special method called by JSON to transform this object into a string suitable to be added in a json data.
type
Set or get the error type. It returns the current value.
SERIALISATION
Serialisation by CBOR, Sereal and Storable::Improved (or the legacy Storable) is supported by this package. To that effect, the following subroutines are implemented: FREEZE, THAW, STORABLE_freeze and STORABLE_thaw
AUTHOR
Jacques Deguest <jack@deguest.jp>
COPYRIGHT & LICENSE
Copyright (c) 2026 DEGUEST Pte. Ltd.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.