Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Locale-Maketext-Lexicon CPAN distribution.

Report information
The Basics
Id: 63722
Status: resolved
Priority: 0/
Queue: Locale-Maketext-Lexicon

People
Owner: Nobody in particular
Requestors: TONVOON [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Errors when loading po files are not propagated
I'm trying to put together a howto I18N for Catalyst. I've lost about 6 hours as my Cat app was failing and I couldn't see how. Turns out that I stupidly didn't set a charset for the po file. After lots of debugging, it turns out that the a die() error from Locale::Maketext::Lexicon (from a call in Locale::Maketext::Simple) was not propagating the error message back upstream, thus failing to report it correctly to Catalyst. I've attached a patch + test case where the error was being hidden incorrectly due to a local $@ call. There maybe a better fix (maybe the local $@ was put for a reason?). However, all tests pass for me.
Subject: Locale_Maketext_Lexicon_error_propagation.patch
diff -uNr Locale-Maketext-Lexicon-0.79/lib/Locale/Maketext/Lexicon.pm Locale-Maketext-Lexicon-0.79.with_error_propagation/lib/Locale/Maketext/Lexicon.pm --- Locale-Maketext-Lexicon-0.79/lib/Locale/Maketext/Lexicon.pm 2010-03-02 15:20:23.000000000 +0000 +++ Locale-Maketext-Lexicon-0.79.with_error_propagation/lib/Locale/Maketext/Lexicon.pm 2010-12-08 00:13:23.000000000 +0000 @@ -295,7 +295,7 @@ next; } - local $@; + #local $@; # This hides errors from calling functions my @content = eval { $class->lexicon_get( $src, scalar caller(1), $lang ); }; next if $@ and $@ =~ /^next\b/; diff -uNr Locale-Maketext-Lexicon-0.79/t/61-badcharset.t Locale-Maketext-Lexicon-0.79.with_error_propagation/t/61-badcharset.t --- Locale-Maketext-Lexicon-0.79/t/61-badcharset.t 1970-01-01 00:00:00.000000000 +0000 +++ Locale-Maketext-Lexicon-0.79.with_error_propagation/t/61-badcharset.t 2010-12-08 00:12:53.000000000 +0000 @@ -0,0 +1,22 @@ +#!/usr/bin/perl -w +use strict; +use Test::More tests => 1; + +require Locale::Maketext::Lexicon; + +package MyApp::I18N::i_default; +# Need below to fake the loading of the po file +our %Lexicon = ( _AUTO => 1 ); + +package main; + +eval " + package MyApp::I18N; + use base 'Locale::Maketext'; + Locale::Maketext::Lexicon->import({ + 'i-default' => [ 'Gettext' => 't/badcharset.po' ], + _decode => 1, + _encoding => undef, + }); + "; +like( $@, qr/Unknown encoding 'CHARSET'/, "Caught bad encoding error" ); diff -uNr Locale-Maketext-Lexicon-0.79/t/badcharset.po Locale-Maketext-Lexicon-0.79.with_error_propagation/t/badcharset.po --- Locale-Maketext-Lexicon-0.79/t/badcharset.po 1970-01-01 00:00:00.000000000 +0000 +++ Locale-Maketext-Lexicon-0.79.with_error_propagation/t/badcharset.po 2010-12-07 23:46:14.000000000 +0000 @@ -0,0 +1,10 @@ +msgid "" +msgstr "" +"Last-Translator: Audrey Tang <cpan@audreyt.org>\n" +"Language-Team: Chinese <contact@ourinet.com>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "This is a test" +msgstr "這是測試"
Hi Ton Thanks for the patch - applied, and v 0.83 released clint