Add logging in send_error