title: Spring - catch bean creation exception
body: <p>I want to catch bean instantiation exceptions in my code. What options do I have?
  One way to do this is to use Java-based container configuration:</p>
  
  <pre><code>@Configuration
  public class AppConfig {
    @Bean
    public SomeBean someBean() {
      try {
        return new SomeBean(); // throws SomeException
      } catch(SomeException se) {
        return new SomeBeanStub();
      }
    }
  }
  </code></pre>
  
  <p>Is that possible to define exception handlers for bean instantiation using Spring using XML-based or annotation-based configuration?</p>