Error handling for positionRelativeTo