read failures of pnm files now report low-level errors
authorTony Cook <tony@develop=help.com>
Tue, 10 Apr 2001 04:00:59 +0000 (04:00 +0000)
committerTony Cook <tony@develop=help.com>
Tue, 10 Apr 2001 04:00:59 +0000 (04:00 +0000)
Imager.pm

index a2d14c69e6f340793d0523563f4572f360fbd6ab..8e81935f783410deca30b482ecc545afea7d7806 100644 (file)
--- a/Imager.pm
+++ b/Imager.pm
@@ -304,6 +304,11 @@ sub unload_plugin {
   return 1;
 }
 
+# take the results of i_error() and make a message out of it
+sub _error_as_msg {
+  return join(": ", map $_->[0], i_errors());
+}
+
 
 #
 # Methods to be called on objects.
@@ -464,7 +469,7 @@ sub read {
 
     if ( $input{type} eq 'pnm' ) {
       $self->{IMG}=i_readpnm_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
-      if ( !defined($self->{IMG}) ) { $self->{ERRSTR}='unable to read pnm image'; return undef; }
+      if ( !defined($self->{IMG}) ) { $self->{ERRSTR}='unable to read pnm image: '._error_as_msg(); return undef; }
       $self->{DEBUG} && print "loading a pnm file\n";
       return $self;
     }