better error handling in rpc.