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.