Add/improve yang parser error reporting
If a yang file fails to load/parse in karaf, it fails silently. The
first problem is that YangTextSchemaContextResolver#getSchemaContext
logs the SchemaResolutionException to debug as it retries with
getResolvedSources. But if getResolvedSources is empty, it ends up
silently returning an empty SchemaContext.
Another issue is that the underlying exceptions that are really relevant
are added as suppressed to the aggregating exception. This would be fine
if the underlying logger in karaf printed suppressed exceptions as
Throwable#printStackTrace does but it doesn't. The suppressed exceptions
do appear from maven (that underlying logger uses printStackTrace).
My first thought was to log the SchemaResolutionException if
SchemaResolutionException was empty but use printStackTrace to get the
suppressed exceptions. However there are 3 levels of exceptions which is
kind of ugly - one needs to sift thru a lot of noise and long stack
traces to find the relevant error.
So. to make it more user-friendly, I instead modified BundleGlobalContext
to log each source exception's suppressed exceptions as these contain the
actual parsing failures. I also only printed the exception message
normally to avoid the stack trace noise. The full trace can be seen with
debug enabled.
Change-Id: Ie603bab3caa4fabc421ffbd106fddd5176743d2b
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>