02-19-2019 01:17 PM
Hi
Is there any way to define custom error-message for data types in yang? For example:
type inet:ipv4-address {
error-message "Invalid IPv4 address for loopback0";
}
PS - the above produces an error: unexpected keyword 'error-message'
02-20-2019 10:01 AM
02-20-2019 10:48 AM
Thanks, yes I have seen that part of RFC but it seems in all the examples error-message is applicable when a condition is evaluated on datatype (for example: range, pattern, etc.). I'm not trying to impose further conditions on "inet:ipv4-address", rather want to just customize the error message that NSO returns to NB API when an invalid IP address is sent. By default, NSO's error-message returned to NB API contains the internal xpath to the IPv4 address in question, I want to customize that to a more generic error message.
02-20-2019 12:55 PM
02-20-2019 04:10 PM
Here's a sample of error-message NSO would return to NB API by default:
"error-message": "invalid value for: loopback0v4 in /myservice:myservice[myservice:device='Router24']/myservice:loopbacks/myservice:loopback0v4: \"10.10.10.1000\" is not a valid value."
02-20-2019 04:21 PM
{native-val} is not a valid value.
02-20-2019 04:24 PM - edited 02-20-2019 04:35 PM
Sorry, it filtered the other info. But bad_value us explained as:
This error type denotes a type error. It is generated when an
invalid value is specified for a certain leaf.
which leads to the following errcodes.
Another thing would be, what is the use-case here? More customization? To me it seems straight forward as to what is wrong, but I understand use cases my vary.
02-20-2019 05:07 PM
yeah good find... I'm not sure how errcode.xml is imported and used inside ncs. If someone could shed more light on it, that would be great... I wish there was some documentation around it (maybe there is?)...
The use-case is simple... we don't necessarily want NSO's default error-messages which refer to the internal structure of service yang to be passed to a NB system/user. Ability to customize/generalize the error text returned to NB systems/users who are unaware of NSO details is very much desired.
02-20-2019 05:11 PM
02-20-2019 05:14 PM
Thanks Joe
02-21-2019 12:03 PM
Hi,
So..As far as I know..only some errors can be altered. If you go to your NSO install directory and go into the man pages > man3 > confd_lib_dp, you can check out a section called 'Error Formatting Callback'. But that is all I can find at the moment. I checked it out myself and I'm not too familiar with this, but as far as I can find, this is the closest to what you are requesting.
Hope this helps!
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: