In this example, the $result initially contains no errors. If the login() is unsuccessful though, add_error() is used to add an error to the password Element. If the user is shown the form again using $result->as_xml, they will be shown an appropriate error message alongside the password field.