Uniformize code for error reporting after a hook.