Closed xorrkaz closed 5 months ago
A simple return
is not sufficient, b/c pyang will in this case exit w/ code 0. The proper way is probably to create an error object in ctx.errors, and then return.
Thanks for the comment. That makes sense. The stderr message is also a bit odd when using the plugin as a library. Given we don't have a module yet, I took a stab at a dummy Position and a new error code.
With this code, the result from a standalone run is:
pyang --check-update-from=foo.yang Cisco-IOS-XE-wireless-location-oper.yang
foo.yang:0: error: error foo.yang: [Errno 2] No such file or directory: 'foo.yang'
If other modules import this code, an exit in a library may have unintended consequences. Like in other places, use return instead of exit.