Issue Details (XML | Word | Printable)

Key: CASTOR-2593
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Werner Guttmann
Reporter: Werner Guttmann
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
castor

Improve exception reporting when custom field handlers are used

Created: 11/Dec/08 07:20 AM   Updated: 24/Jan/09 11:12 AM   Resolved: 12/Dec/08 03:16 PM
Return to search
Component/s: XML
Affects Version/s: 1.3 rc1
Fix Version/s: 1.3

Time Tracking:
Original Estimate: 10 minutes
Original Estimate - 10 minutes
Remaining Estimate: 10 minutes
Remaining Estimate - 10 minutes
Time Spent: Not Specified
Time Spent - Not Specified


 Description  « Hide

Currently, if a custom FieldHandler throws an Exception, this exception is not being reported in the IllegalArgumentException being thrown by the framework. This should be changed



Werner Guttmann made changes - 11/Dec/08 07:20 AM
Field Original Value New Value
Assignee Werner Guttmann [ wguttmn ]
Werner Guttmann added a comment - 11/Dec/08 07:20 AM

Possible patch:

### Eclipse Workspace Patch 1.0
#P castorASE09
Index: xml/src/main/java/org/exolab/castor/mapping/loader/FieldHandlerImpl.java
===================================================================
--- xml/src/main/java/org/exolab/castor/mapping/loader/FieldHandlerImpl.java	(revision 7978)
+++ xml/src/main/java/org/exolab/castor/mapping/loader/FieldHandlerImpl.java	(working copy)
@@ -504,22 +504,24 @@
                 }
                 // If the field has no set method, ignore it.
                 // If this is a problem, identity it someplace else.
-            } catch ( IllegalArgumentException except ) {
+            } catch (IllegalArgumentException except) {
                 // Graceful way of dealing with unwrapping exception
-                if ( value == null )
-                    throw new IllegalArgumentException( Messages.format( "mapping.typeConversionNull", toString() ) );
-                throw new IllegalArgumentException( Messages.format( "mapping.typeConversion",
-                                                                     toString(), value.getClass().getName() ) );
-            } catch ( IllegalAccessException except ) {
+                if (value == null) {
+                    String errorMessage = Messages.format("mapping.typeConversionNull", toString());
+                    throw new IllegalArgumentException(errorMessage);
+                }
+                String errorMessage = Messages.format("mapping.typeConversion", 
+                        toString(), value.getClass().getName());
+                throw new IllegalArgumentException(errorMessage, except);
+            } catch (IllegalAccessException except) {
                 // This should never happen
-                throw new CastorIllegalStateException(
-                        Messages.format("mapping.schemaChangeNoAccess", toString()),
-                        except);
-            } catch ( InvocationTargetException except ) {
+                String errorMessage = 
+                    Messages.format("mapping.schemaChangeNoAccess", toString());
+                throw new CastorIllegalStateException(errorMessage, except);
+            } catch (InvocationTargetException except) {
                 // This should never happen
                 throw new MappingRuntimeException(except.getTargetException());
             }
-
         } else if ( value != null ) {
             Object collect;
             try {

Werner Guttmann made changes - 12/Dec/08 03:16 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Ralf Joachim made changes - 22/Jan/09 10:58 AM
Fix Version/s 1.3.1 [ 14004 ]
Fix Version/s 1.3 [ 14917 ]
Ralf Joachim made changes - 24/Jan/09 11:12 AM
Status Resolved [ 5 ] Closed [ 6 ]