@domcleal good catch. The call to datacenter is needed to report the error correctly.
I have added it back in the next line because it needed to be after the update_public_key call.