Better error handling for HG