Depends on the scope.
In the business logic word “user is not authorized / authenticated”, the situation is exceptional and should lead to an exception of the runtime, for example (Java code):
public String salutation(User user) {
return String.format("Hello, %s!", user.getName());
}
User (, , ) , NonAuthenticatedException getName().
/ , :
if (!user.isAuthenticated()) {
httpResponse.addHeader("WWW-Authenticate", "Basic realm=\"secure content\"");
}