aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2017-11-16 16:58:07 +0000
committerBrian Cully <bjc@kublai.com>2017-11-16 16:58:07 +0000
commit1e1ec4b702735e83dc956673816c6c2d8d333596 (patch)
tree338baea1db2f4893b2c3c27bd78d4b432e338780
parent1a548e6be0318339711dd4e7b539e3a26647265c (diff)
downloadxmpt-1e1ec4b702735e83dc956673816c6c2d8d333596.tar.gz
xmpt-1e1ec4b702735e83dc956673816c6c2d8d333596.zip
Add eval at top level to log exceptions.
-rwxr-xr-xxmpt38
1 files changed, 21 insertions, 17 deletions
diff --git a/xmpt b/xmpt
index 3d7cb3f..2546092 100755
--- a/xmpt
+++ b/xmpt
@@ -32,24 +32,28 @@ usage(0) if $help;
$| = 1;
-local %evalpkg::env = read_env($envpath);
-my @plans = load_plans($testplanpath, $templatepath);
-
-# Ignore SIGPIPE at the top level, since it only matters when reading
-# or writing to the subprocess.
-local $SIG{PIPE} = sub {};
-
-my ($inh, $outh) = (\*STDIN, \*STDOUT);
-my $pid;
-if (@ARGV) {
- $inh = $outh = undef;
- $pid = open2($inh, $outh, join(' ', @ARGV));
-}
-binmode($inh, ':utf8');
-binmode($outh, ':utf8');
+eval {
+ local %evalpkg::env = read_env($envpath);
+ my @plans = load_plans($testplanpath, $templatepath);
+
+ # Ignore SIGPIPE at the top level, since it only matters when
+ # reading or writing to the subprocess.
+ local $SIG{PIPE} = sub {};
+
+ my ($inh, $outh) = (\*STDIN, \*STDOUT);
+ my $pid;
+ if (@ARGV) {
+ $inh = $outh = undef;
+ $pid = open2($inh, $outh, join(' ', @ARGV));
+ }
+ binmode($inh, ':utf8');
+ binmode($outh, ':utf8');
+
+ eval_in($inh, $outh, @plans);
+ waitpid($pid, 0) if $pid;
-eval_in($inh, $outh, @plans);
-waitpid($pid, 0) if $pid;
+ 1;
+} or error($@) and exit 3;
# TODO: swap over to Pod::Usage.
sub usage {