App-CELL
view release on metacpan or search on metacpan
lib/App/CELL/Guide.pm view on Meta::CPAN
The calling function could check the return value like this:
my $status = foo_dis();
return $status if $status->not_ok;
my $displacement = $status->payload;
For details, see L<App::CELL::Status> and L<App::CELL::Message>.
CELL's error-handling logic is inspired by brian d foy's article "Return
error objects instead of throwing exceptions"
L<http://www.effectiveperlprogramming.com/2011/10/return-error-objects-instead-of-throwing-exceptions/>
=head2 Localization
This CELL component, called "Localization", gives the programmer a way to
encapsulate a "message" (in its simplest form, a string) within a message
object and then use that object in various ways.
So, provided the necessary message files have been loaded, the programmer
could do this:
lib/App/CELL/Message.pm view on Meta::CPAN
{ $msgobj->{lang} }->
{ 'File' } || '<NONE>';
$msgobj->{'line'} = $mesg->
{ $msgobj->{code} }->
{ $msgobj->{lang} }->
{ 'Line' } || '<NONE>';
# This next line is important: it may happen that the developer wants
# to quickly code some messages/statuses without formally assigning
# codes in the site configuration. In these cases, the $mesg lookup
# will fail. Instead of throwing an error, we just generate a message
# text from the value of 'code'.
my $text = $mesg->
{ $msgobj->{code} }->
{ $msgobj->{lang} }->
{ 'Text' }
|| $msgobj->{code};
# strip out anything that resembles a newline
$text =~ s/\n//g;
$text =~ s/\012/ -- /g;
( run in 0.320 second using v1.01-cache-2.11-cpan-496ff517765 )