git.shiar.nl
/
barcat.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0439a48
)
catch errors in report templates
author
Mischa POSLAWSKY
<perl@shiar.org>
Sun, 20 Nov 2022 22:49:16 +0000
(23:49 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Tue, 22 Nov 2022 23:06:47 +0000
(
00:06
+0100)
barcat
patch
|
blob
|
history
diff --git
a/barcat
b/barcat
index 189c8ff72b3688ce8fcd8984313d30503da199d4..6dbddd97910941e84542173cfff807318eaa906a 100755
(executable)
--- a/
barcat
+++ b/
barcat
@@
-384,10
+384,19
@@
sub show_stat {
sub varfmt {
my ($fmt, $vars) = @_;
$fmt =~ s[\$\{ (\w+) (?<cmd>; (?: [^{}]+ | \{.*?\} )*)? \}]{
sub varfmt {
my ($fmt, $vars) = @_;
$fmt =~ s[\$\{ (\w+) (?<cmd>; (?: [^{}]+ | \{.*?\} )*)? \}]{
- local $_ = $vars->{$1}; #TODO //
- $_ = $opt{'value-format'}->($_) if $opt{reformat};
- eval $+{cmd} if $+{cmd}; #TODO $@
- $_;
+ local $_ = $vars->{$1};
+ if (defined) {
+ $_ = $opt{'value-format'}->($_) if $opt{reformat};
+ if ($+{cmd}) {
+ eval $+{cmd};
+ warn "Error in \$$1 report: $@" if $@;
+ }
+ $_;
+ }
+ else {
+ warn "Unknown variable \$$1 in report\n";
+ "\$$1";
+ }
}eg;
return $fmt;
}
}eg;
return $fmt;
}