I would guess that you see the error because no user is logged in (and thus asking for the name of a non-existent user throws an error)… Note that remote users don’t count for these purposes.
Try this:
if exists current user then name of current user else “no user logged in”