Commit c91c7655 authored by Leigh B Stoller's avatar Leigh B Stoller

Improve dataset/image urn sanity checking and error reporting, to make

sure the errors go to the user instead of us.
parent e1ed5ace
...@@ -116,6 +116,7 @@ DBConnect(GENISA_DBNAME()); ...@@ -116,6 +116,7 @@ DBConnect(GENISA_DBNAME());
# Protos # Protos
sub fatal($); sub fatal($);
sub MyExit($$);
sub CreateSlivers(); sub CreateSlivers();
sub RunStitcher(); sub RunStitcher();
sub CallMethodOnAggregate($$$); sub CallMethodOnAggregate($$$);
...@@ -275,13 +276,19 @@ if (! (defined($speaksfor_credential) && ...@@ -275,13 +276,19 @@ if (! (defined($speaksfor_credential) &&
my $dataset_credentials = {}; my $dataset_credentials = {};
my $retval = $instance->CreateDatasetCreds(\$errmsg, \$dataset_credentials); my $retval = $instance->CreateDatasetCreds(\$errmsg, \$dataset_credentials);
if ($retval) { if ($retval) {
fatal("Could not generate dataset credentials: $errmsg"); # Map user error to BADARGS,
$retval = GENIRESPONSE_BADARGS()
if ($retval == 1);
MyExit($retval, "Could not generate dataset credentials: $errmsg");
} }
# Ditto images that are not global (also checks user permission). # Ditto images that are not global (also checks user permission).
my $image_credentials = {}; my $image_credentials = {};
$retval = $instance->CreateImageCreds(\$errmsg, \$image_credentials); $retval = $instance->CreateImageCreds(\$errmsg, \$image_credentials);
if ($retval) { if ($retval) {
fatal("Could not generate image credentials: $errmsg"); # Map user error to BADARGS,
$retval = GENIRESPONSE_BADARGS()
if ($retval == 1);
MyExit($retval, "Could not generate image credentials: $errmsg");
} }
# #
...@@ -1277,9 +1284,9 @@ sub RunStitcher() ...@@ -1277,9 +1284,9 @@ sub RunStitcher()
return $errcode; return $errcode;
} }
sub fatal($) sub MyExit($$)
{ {
my ($mesg) = @_; my ($code, $mesg) = @_;
$genislice->UnLock() $genislice->UnLock()
if (defined($genislice)); if (defined($genislice));
...@@ -1288,12 +1295,18 @@ sub fatal($) ...@@ -1288,12 +1295,18 @@ sub fatal($)
if (defined($webtask)) { if (defined($webtask)) {
$webtask->output($mesg); $webtask->output($mesg);
$webtask->Exited(-1); $webtask->Exited($code);
} }
print STDERR "*** $0:\n". print STDERR "*** $0:\n".
" $mesg\n"; " $mesg\n";
# Exit with negative status so web interface treats it as system error. exit($code);
exit(-1); }
sub fatal($)
{
my ($mesg) = @_;
MyExit(-1, $mesg);
} }
# #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment