Catch exception raised when pkg.refresh_db is called

This catches an exception that may be raised as part of the code added
in #14812.
Merge pull request #15103 from terminalmage/pkg.latest-catch-exception

Catch exception raised when pkg.refresh_db is called