Permalink
Browse files

Catching error, some strange problem with Module::Data added workarou…

…nd for this
  • Loading branch information...
1 parent a8cd7e4 commit 7e6aa202e38fc009ac4c82d00c442c83d91190e3 @Getty Getty committed Jun 7, 2012
Showing with 34 additions and 30 deletions.
  1. +2 −1 lib/App/DuckPAN.pm
  2. +29 −13 lib/App/DuckPAN/Cmd/Query.pm
  3. +0 −15 lib/App/DuckPAN/Help.pm
  4. +3 −1 lib/App/DuckPAN/Perl.pm
View
@@ -241,13 +241,14 @@ sub get_local_ddg_version {
sub check_ddg {
my ( $self ) = @_;
my $ok = 1;
+ my $installed_version = $self->get_local_ddg_version;
+ return $ok if $installed_version && $installed_version == '9.999';
print "Checking for latest DDG Perl package... ";
my $tempfile = tmpnam;
if (is_success(getstore($self->duckpan_packages,$tempfile))) {
my $packages = Parse::CPAN::Packages::Fast->new($tempfile);
my $module = $packages->package('DDG');
my $latest = $self->duckpan.'authors/id/'.$module->distribution->pathname;
- my $installed_version = $self->get_local_ddg_version;
if ($installed_version && version->parse($installed_version) >= version->parse($module->version)) {
print $installed_version;
print " (duckpan has ".$module->version.")" if $installed_version ne $module->version;
@@ -15,20 +15,36 @@ sub run {
print "\n(Empty query for ending test)\n";
while (my $query = $self->app->get_reply( 'Query: ' ) ) {
- my $request = DDG::Request->new( query_raw => $query );
- my $hit;
- for (@blocks) {
- my ($result) = $_->request($request);
- if ($result) {
- $hit = 1;
- print "\n";
- p($result);
- print "\n";
- last;
+ eval {
+ my $request = DDG::Request->new( query_raw => $query );
+ my $hit;
+ for (@blocks) {
+ my ($result) = $_->request($request);
+ if ($result) {
+ $hit = 1;
+ print "\n";
+ p($result);
+ print "\n";
+ last;
+ }
}
- }
- unless ($hit) {
- print "\nSorry, no hit on your plugins\n\n";
+ unless ($hit) {
+ print "\nSorry, no hit on your plugins\n\n";
+ }
+ };
+ if ($@) {
+ my $error = $@;
+ if ($error =~ m/Malformed UTF-8 character/) {
+ print "\n[WARNING] You got a malformed utf8 error message, which normally means\n";
+ print "that you try to entered a special character on the query prompt, but your\n";
+ print "interface is not proper configured towards utf8. Please checkout the\n";
+ print "documentation of your terminal, ssh client or whatever client you use\n";
+ print "to access the shell of this system\n\n";
+ print "Here the original error message:\n\n";
+ } else {
+ print "\nCatched error:\n\n";
+ }
+ print $error."\n";
}
}
print "\n\n\\_o< Thanks for testing!\n\n";
View
@@ -18,11 +18,6 @@ sub header { my $version = shift->version; return <<"__EOT__"; }
__EOT__
sub help { return shift->header().<<'__EOT__'; }
-=> You need an account at https://dukgo.com/
-
-duckpan setup
--------------
- Initialize your DuckPAN development environment
duckpan check
-------------
@@ -58,13 +53,3 @@ duckpan faq
__EOT__
1;
-
-sub goodie { return shift->header().<<'__EOT__'; }
-duckpan goodie new MyGoodie
-------------------------------------------------
- Starts a new goodie 'DDG::Goodie::MyGoodie' in 'p5-ddg-goodie-mygoodie'
- (may be renamed, will check if setup was run)
-
-__EOT__
-
-1;
View
@@ -45,7 +45,9 @@ sub get_local_version {
{
local $@;
eval {
- $v = Module::Data->new( $module )->version;
+ my $m = Module::Data->new( $module );
+ $m->require;
+ $v = $m->version;
1
} or return;
};

0 comments on commit 7e6aa20

Please sign in to comment.