Index: trunk/ippScripts/scripts/register_exp.pl
===================================================================
--- trunk/ippScripts/scripts/register_exp.pl	(revision 20429)
+++ trunk/ippScripts/scripts/register_exp.pl	(revision 22430)
@@ -27,4 +27,13 @@
 my $ipprc = PS::IPP::Config->new();
 
+# Look for commands we need
+my $missing_tools;
+my $regtool = can_run('regtool') or (warn "can't find regtool" and $missing_tools = 1);
+my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
+if ($missing_tools) {
+    warn ("Can't find required tools");
+    exit($PS_EXIT_CONFIG_ERROR);
+}
+
 my ($cache, $exp_id, $exp_tag, $label, $dvodb, $end_stage, $tess_id, $dbname, $verbose, $no_update, $no_op, $save_temps, $logfile);
 GetOptions(
@@ -33,8 +42,8 @@
     'exp_tag|t=s'   => \$exp_tag,
     'dbname|d=s'    => \$dbname, # Database name
-    'label=s'       => \$label,   
-    'dvodb=s'       => \$dvodb,   
-    'end_stage=s'   => \$end_stage, 
-    'tess_id=s'     => \$tess_id,   
+    'label=s'       => \$label,
+    'dvodb=s'       => \$dvodb,
+    'end_stage=s'   => \$end_stage,
+    'tess_id=s'     => \$tess_id,
     'verbose'       => \$verbose,   # Print to stdout
     'no-update'     => \$no_update,
@@ -44,4 +53,8 @@
 ) or pod2usage( 2 );
 
+# Unhandled exceptions should be passed on to my_die so they get pushed into the database
+$SIG{__DIE__} = sub { die @_ if $^S;
+                      my_die( $_[0], $exp_id, $PS_EXIT_UNKNOWN_ERROR ); };
+
 $ipprc->redirect_output($logfile) if $logfile;
 
@@ -55,14 +68,4 @@
 my @SCIENCE = ( "object", "science", "light" ); # Observation types to NOT mark as detrend
 my $DETREND_FLAG = "-end_stage reg"; # Flag to use to mark detrend exposure
-
-# Look for commands we need
-my $missing_tools;
-my $regtool = can_run('regtool') or (warn "can't find regtool" and $missing_tools = 1);
-my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
-
-if ($missing_tools) {
-    warn ("Can't find required tools");
-    exit($PS_EXIT_CONFIG_ERROR);
-}
 
 # setup cache interface
@@ -123,7 +126,7 @@
 $command .= " -exp_tag $exp_tag";
 $command .= " -hostname  $host"      if defined $host;
-$command .= " -dbname 	 $dbname"    if defined $dbname;
-$command .= " -label  	 $label"     if defined $label;
-$command .= " -dvodb  	 $dvodb"     if defined $dvodb;
+$command .= " -dbname    $dbname"    if defined $dbname;
+$command .= " -label     $label"     if defined $label;
+$command .= " -dvodb     $dvodb"     if defined $dvodb;
 $command .= " -end_stage $end_stage" if defined $end_stage;
 $command .= " -tess_id   $tess_id"   if defined $tess_id;
