cleaned up error handling in sh.connect