Skip to content

Commit

Permalink
Tag import-fields: make error handling more robust
Browse files Browse the repository at this point in the history
Some database types' set_slice do not eval, and thus do not reliably
set $@ so we should clear it first.

Include $@ if it is set. This is still messy, because an unrelated eval
in set_slice or something it calls could leave a bogus error, but without
rewriting every set_slice completely, this is the best we can do.

The set_slice method returns undef on failure or a new key on success,
so check for that instead.
  • Loading branch information
jonjensen committed Nov 2, 2017
1 parent 416109f commit ff51f57
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions code/UI_Tag/import_fields.coretag
@@ -1,4 +1,4 @@
# Copyright 2002-2007 Interchange Development Group and others
# Copyright 2002-2009 Interchange Development Group and others
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -7,7 +7,7 @@

UserTag import_fields Order table
UserTag import_fields addAttr
UserTag import_fields Version $Revision: 1.15 $
UserTag import_fields Version 1.16
UserTag import_fields Routine <<EOR
sub {
my($table, $opt) = @_;
Expand Down Expand Up @@ -421,13 +421,18 @@ EOF
}
}

$db->set_slice($k, \%hash) if @names;
if (@names) {
undef $@;
my $key = $db->set_slice($k, \%hash);
unless ($key) {
my $msg_raw = "error on update";
$msg_raw .= ": $@" if $@;
my $msg = ::errmsg($msg_raw);
::logError($msg);
$out .= $msg;
}
}

if($@) {
my $msg = ::errmsg("error on update: %s", $@);
::logError($msg);
$out .= $msg;
}
$count++;
}

Expand Down

0 comments on commit ff51f57

Please sign in to comment.