title: java ee cdi: catch exception thrown by producer method
body: <p>is it possible to catch an Exception that is thrown by a producer method in Java CDI? I have following producer method</p>
  
  <pre><code>@Produces
  public User getLoggedInUser() throws UserNotLoggedInException {
      if(...){
          throw new UserNotLoggedInException();
      }
      User user = ... 
      ...
      return user;
  }
  </code></pre>
  
  <p>and i want to inject the user object somewhere. I cannot write the method like this:</p>
  
  <pre><code>private void doSomethingWithUser(){
      try {
          User loggedInUser = user.get(); // throws exception
      } catch (UserNotLoggedInException e){  // Compiler compains
          ...
      }
  }
  </code></pre>
  
  <p>As the compiler says that the <code>UserNotLoggedInException</code> is not thrown in any method. If i catch a generic <code>Exception</code>, everything works fine. Is there a more elegant solution to this problem? </p>
  
  <p>Thanks</p>