Fix error handling in lhash contract