I\'d like to use
java.util.Optional.orElseThrow()
with an Exception type that asks for a constructor parameter. Something like this:
optionalUsers.orElseThrow(() -> new UsernameNotFoundException("Username not found"));