[
http://jira.codehaus.org/browse/JIBX-204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dennis Sosnoski closed JIBX-204.
--------------------------------
> Provide more information about which field failed when unmarshalling
> --------------------------------------------------------------------
>
> Key: JIBX-204
> URL: http://jira.codehaus.org/browse/JIBX-204
> Project: JiBX
> Issue Type: Improvement
> Components: core
> Affects Versions: JiBX 1.1.5
> Environment: All
> Reporter: Joshua Davies
> Assignee: Dennis Sosnoski
> Fix For: JiBX 1.1.6
>
> Attachments: jibx_issue_204_src.diff, jibx_issue_204_test.diff
>
>
> When Jibx encounters a malformed element (for example, an invalid boolean or
> integer value), the caller is not provided with much information on which
> field was malformed. Line & column numbers are supplied, but it's not always
> easy to match those up with the request text. It would be easy if jibx could
> state which field it was parsing and what invalid value it encountered.
> Here's a concrete example. Suppose I have this simple binding:
> <binding direction="input" track-source="true">
> <mapping name="target" class="Target">
> <value name="bool1" field="bool1" />
> </mapping>
> </binding>
> And I give it this invalid input:
> <target>
> <bool1>abc</bool1>
> </target>
> The response I'm going to get back from the runtime will be:
> Exception in thread "main" org.jibx.runtime.JiBXException: Invalid boolean
> value (line 3, col 2)
> at
> org.jibx.runtime.impl.UnmarshallingContext.convertBoolean(UnmarshallingContext.java:1847)
> at
> org.jibx.runtime.impl.UnmarshallingContext.parseElementBoolean(UnmarshallingContext.java:1904)
> at Target.JiBX_binding_unmarshal_1_0(Target.java)
> at JiBX_bindingTarget_access.unmarshal()
> at
> org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2537)
> at
> org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2694)
> at Main.main(Main.java:17)
> First of all - the line and column numbers don't match my sample document
> (I'm still researching to figure out exactly why).
> However, even with correct line & column numbers, it would be helpful to see:
> Exception in thread "main" org.jibx.runtime.JiBXException: Invalid boolean
> value 'abc' for field 'bool1' (line 2, col 3)
> I've looked through the UnmarshallingContext source code, and it appears that
> it wouldn't be terribly difficult to add this information. For example, the
> call stack for the boolean above is:
> UnmarshallingContext.parseElementBoolean( String ns, String tag )
> UnmarshallingContext.convertBoolean( String text )
> convertBoolean throws an instance of JiBXException on a malformed value.
> I propose creating a JiBXException subclass named JiBXParseException with
> three additional fields: m_namespace, m_tag, m_value.
> Then convertBoolean (and convertFloat, convertShort, etc.) can set the
> m_value at constructor time. Finally, parseElementBoolean (and
> parseElementFloat and attributeBoolean and attributeFloat, etc.) can catch
> the exception, add the namespace & tag information and rethrow it.
> If everybody agrees that this is a worthwhile endeavor, I would be happy to
> prepare a patch and submit it.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs