'require' not 'use' Fax::Hylafax::Client so it's an optional requirement.
authorkhoff <khoff>
Tue, 29 Mar 2005 01:38:51 +0000 (01:38 +0000)
committerkhoff <khoff>
Tue, 29 Mar 2005 01:38:51 +0000 (01:38 +0000)
FS/FS/Misc.pm

index a7cd471..7d7b7d0 100644 (file)
@@ -50,7 +50,6 @@ use Date::Format;
 use Mail::Header;
 use Mail::Internet 1.44;
 use MIME::Entity;
-use Fax::Hylafax::Client;
 use FS::UID;
 
 FS::UID->install_callback( sub {
@@ -136,6 +135,18 @@ sub send_fax {
   die 'HylaFAX support has not been configured.'
     unless $conf->exists('hylafax');
 
+  eval {
+    require Fax::Hylafax::Client;
+  };
+
+  if ($@) {
+    if ($@ =~ /^Can't locate Fax.*/) {
+      die "You must have Fax::Hylafax::Client installed to use invoice faxing."
+    } else {
+      die $@;
+    }
+  }
+
   my %hylafax_opts = map { split /\s+/ } $conf->config('hylafax');
 
   die 'Called send_fax without a \'dialstring\'.'