Handle exceptions thrown in rpc functions.