title: Custom Exception thrown in Java should be shown in Thymeleaf
body: <p>I want to show my custom exception that is being thrown in Java code in Thymeleaf.</p>
  
  <pre><code>@Override
  public UserDetails loadUserByUsername(String benutzername) throws UsernameNotFoundException {
      Benutzer benutzer = userRepository.findByBenutzername(benutzername);
      if (benutzer == null || ! benutzer.isActive()) {
          throw new UsernameNotFoundException("Wrong username or password was provided!");
      }
  
  &lt;div th:if="${param.error}" &gt;
      &lt;div class="alert alert-danger"&gt;
          Here should my custom exception appear from above.
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I throw a new UsernameNotFoundException with a custom exception and this exception should be shown in my template, however, I do not know how this should be done.</p>