improving exception reporting and preventing broken jars to be uploaded
(cherry picked from commit dd6d1e324b337127e77d6bdffdda111a155998ef)