Hello Everyone,
Below is a patch (really a change from -- to section since I couldn't
figure out how to get TortoiseSVN to produce patches on windows), to
produce nicer error messages (instead of internal server errors from
apache) for duplicate uploaded package names. Current if you upload
'foobar-0.1.tar.gz' twice you receive a 500 error. This will roughly
try to figure out that it is a duplicate or display the internal mysql
error.
I cannot test this since I don't have the full openjsan app setup on a
local machine (or anything besides the source code).
Change:
$user->add_to_distributions({filename => "$file->{filename}"});
To:
## catch db error
eval { $user->add_to_distributions({filename => "$file->{filename}"});
};
my $err = $@;
## try to detect error (slightly) and create nicer one,
## if not dump db error
$err = sprintf("'%s' version already exists, please update version
number", $file->{filename}) if ($err =~ /duplicate entry/i);
return { error => $err } if $err;
Let me know if I'm way off base here. I couldn't quite figure out the
magic behind the 'add_to_distributions' but I kind of guessed it was
tied to 'Class::DBI::Loader' for the table 'distributions' related to
an 'author'.
Take Care,
Lee