This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 116989

Summary: Cannot specify custom exception handling behavior for components/beans
Product: guibuilder Reporter: jschek <jschek>
Component: CodeAssignee: issues@guibuilder <issues>
Status: NEW ---    
Severity: blocker CC: hmichel, kalle1, misterm
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description jschek 2007-09-27 22:45:37 UTC
In the GUI/Form Editor, there is no easy way to specify a custom exception behavior for a component that throws 
exceptions on bean getter/setter methods. Currently, the editor will generate a try/catch whose behavior is to print 
the exception and move on. This may result in the form initialization to leave the component in an invalid or 
unexpected state.

While the libraries that have this behavior are rare, this has a major impact on the usability of the GUI editor when 
working with those GUI libraries. It is common when using a GUI library that involves the use of JNI, J-Integra, or 
sockets. The problem is severe enough to warrant going back to hand-coded SWING initialization.

This is the code that is currently generated by the GUI editor:

   private void initComponents() {
        esriMapBean = new com.esri.arcgis.beans.map.MapBean();
   //... this block is the exception handling provided by Netbeans
        try {
            esriMapBean.setKeyIntercept(1);
        } catch (java.io.IOException e1) {
            e1.printStackTrace(); //I really need to pass this IOException back up or wrap it in a RuntimeException
        }
   //... if this fails, it can leave my form in a bad state...
   }



Currently, the only work-around is to add the component and ignore the properties editor. Then use the Post-Init Code 
property to set these properties by hand.

Not sure what the permanent solution should be. A stop-gap solution could be to add a "Default Exception Handler" for 
the component initialization. If defined, all exception would get passed to the handler where I could specify my own 
code. If not specified, then continue with the existing behavior.

Something like this:

This would be more desirable:
   private MyPanel() {
      try {
         initComponents();
      } catch(InvocationTargetExceptione) {
         //my default handler code goes here
      }
   }

   private void initComponents() throws InvocationTargetException{
        esriMapBean = new com.esri.arcgis.beans.map.MapBean();
        try {
            esriMapBean.setKeyIntercept(1);
        } catch (java.io.IOException e1) {
            //maybe a different exception--desirable to have the Bean and the property
            throw new InvocationTargetException(e1,"esriMapBean.keyIntercept"); //i.e. wrap exception + bean.property
        }
   }
Comment 1 Tomas Pavek 2009-01-29 18:02:49 UTC
*** Issue 157573 has been marked as a duplicate of this issue. ***
Comment 2 Michel Graciano 2009-02-02 17:40:03 UTC
Any chance to see it for 7.0?
Comment 3 Tomas Pavek 2009-09-30 15:14:28 UTC
*** Issue 173369 has been marked as a duplicate of this issue. ***
Comment 4 kalle1 2015-09-28 01:04:08 UTC
A workaround seems to add a `throws` statement to `initComponents` by opening it in an external editor.