[YANGTOOLS-763] yang-data-codecs: improve validation error reporting Created: 22/Mar/17  Updated: 10/Apr/22  Resolved: 16/Apr/20

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: 5.0.0

Type: Improvement
Reporter: Robert Varga Assignee: Tadey Bilan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Blocks
is blocked by YANGTOOLS-176 Introduce YANGException & YANGError i... Resolved

 Description   

Our current codecs throw a generic IllegalArgumentException when data passes parsing but fails validation (such as pattern, length or range constraints). This results in loss of information in schema, as these constraints can carry additional information.

Introduce a specialized subclass of IllegalArgumentException which will contain:

  • string value being parsed
  • ConstraintMetaDefinition which was violated

Once defined, make all codec instances throw this exception instead of IAE when validation fails.



 Comments   
Comment by Robert Varga [ 22/Mar/17 ]

This exception should be hosted in yang.data.api.codec and all codecs which can be constrained with a ConstraintMetaDefinition relevant during deserialization should have their deserialize() method documented (in javadoc) to throw this exception.

Generated at Wed Feb 07 20:54:14 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.