I don't seem to find this in usage scenarios for the visitor pattern (or maybe I don't get it). It's also not hierarchical.
Let's use an authentication example. A UserAuthenticator authenticates credentials given by a user. It returns a result object. The result object contains the result of the authentication: authentication succeeded, not succeeded because username was not found, not succeeded because illegal characters were used etc. Client code may resort to conditionals to handle this. In pseudocode:
AuthResult = Userauthenticator.authenticate(Username, Password)
if AuthResult.isAuthenticated: do something
else if AuthResult.AuthFailedBecauseUsernameNotFound: do something else
else if etc...
Would a visitor pattern fit here? :
Authresult.acceptVisitor(AuthVisitor)
Authresult then calls a method on AuthVisitor depending on the result :
AuthVisitor.handleNotAuthenticatedBecauseUsernameNotFound