freeside/FS/FS cust_bill.pm,1.131,1.132

Ivan Kohler ivan at pouncequick.420.am
Tue Jun 14 21:46:53 PDT 2005


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory pouncequick:/tmp/cvs-serv26898/FS/FS

Modified Files:
	cust_bill.pm 
Log Message:
better error reporting for actual errors from lpr command

Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- cust_bill.pm	15 Jun 2005 00:44:28 -0000	1.131
+++ cust_bill.pm	15 Jun 2005 04:46:50 -0000	1.132
@@ -3,6 +3,7 @@
 use strict;
 use vars qw( @ISA $DEBUG $conf $money_char );
 use vars qw( $invoice_lines @buf ); #yuck
+use IPC::Run3;
 use Date::Format;
 use Text::Template 1.20;
 use File::Temp 0.14;
@@ -631,7 +632,7 @@
 
 =item lpr_data [ TEMPLATENAME ]
 
-Returns the postscript or plaintext for this invoice.
+Returns the postscript or plaintext for this invoice as an arrayref.
 
 TEMPLATENAME, if specified, is the name of a suffix for alternate invoices.
 
@@ -657,12 +658,14 @@
   my $template = scalar(@_) ? shift : '';
 
   my $lpr = $conf->config('lpr');
-  open(LPR, "|$lpr")
-    or die "Can't open pipe to $lpr: $!\n";
-  print LPR @{ $self->lpr_data($template) };
-  close LPR
-    or die $! ? "Error closing $lpr: $!\n"
-              : "Exit status $? from $lpr\n";
+
+  my $outerr = '';
+  run3 $lpr, $self->lpr_data($template), \$outerr, \$outerr;
+  if ( $? ) {
+    $outerr = ": $outerr" if length($outerr);
+    die "Error from $lpr (exit status ". ($?>>8). ")$outerr\n";
+  }
+
 }
 
 =item fax [ TEMPLATENAME ] 




More information about the freeside-commits mailing list