[YANGTOOLS-538] Yang parser exceptions should follow consistent path Created: 27/Oct/15  Updated: 10/Apr/22  Resolved: 16/Jan/16

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

Type: Bug
Reporter: Tom Pantelis Assignee: Igor Foltin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 4540

 Description   

The build methods in BuildGlobalContext declare SourceException and ReactorException to be thrown and it seems the intention is for completePhaseAction to assemble all SourceException errors into a single checked ReactorException.

However, there are several (maybe many) yang syntax violations that cause unchecked exceptions to be thrown, eg IllegalStateException and IllegalArgumentException.

If you specify an invalid type, eg "string1":

typedef revision-identifier {
type string1

{ ... }

}

you'll see an IllegalStateException thrown. If you specify an invalid yang statement like "grouping1" instead of "grouping", you'll see an IllegalArgumentException.

The code should be consistent and only propagate errors via the declared checked exceptions.



 Comments   
Comment by Tony Tkacik [ 28/Oct/15 ]

Changed to Change Request, since it proposes changing of implementation.

Actually there are three types of base exceptions which should be thrown / generated during parsing (subclassing them to more specific seems fine):

ReactorException - collection of SourceException and InferenceException that happened during parsing.

SourceException - problem itself is in YANG source
InferenceException - e.g. referencing non-existing grouping, etc.

Comment by Igor Foltin [ 11/Jan/16 ]

Fix pushed:

https://git.opendaylight.org/gerrit/#/c/31078/

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