libnetconf2 icon indicating copy to clipboard operation
libnetconf2 copied to clipboard

Custom error message content

Open Prdp2710 opened this issue 5 years ago • 1 comments

Hi,

Is it possible create custom error message content. Is there a some call back which I can register to my function for error construction.

I need to construct an error like such

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="7">
  <rpc-error>
    <error-type>application</error-type>
    <error-tag>data-missing</error-tag>
    <error-severity>error</error-severity>
    <error-app-tag>instance-required</error-app-tag>
    <error-path xmlns:oc-sys="http://openconfig.net/yang/system">
    /rpc/edit-config/config/oc-sys:system/oc-sys:logging/oc-sys:remote-servers/oc-sys:remote-server[oc-sys:host='^10.0.0.112$']/oc-sys:host
  </error-path>
    <error-message xml:lang="en">Invalid parameters</error-message>
    <error-info xmlns:tailf="http://tail-f.com/ns/netconf/params/1.1"
                xmlns:oc-sys="http://openconfig.net/yang/system">
      <tailf:bad-keyref>
        <tailf:bad-element>/oc-sys:system/oc-sys:logging/oc-sys:remote-servers/oc-sys:remote-server[oc-sys:host='^10.0.0.112$']/oc-sys:host</tailf:bad-element>
        <tailf:missing-element>/oc-sys:system/oc-sys:logging/oc-sys:remote-servers/oc-sys:remote-server[oc-sys:host='^10.0.0.112$']/oc-sys:config/oc-sys:host</tailf:missing-element>
      </tailf:bad-keyref>
    </error-info>
  </rpc-error>
</rpc-reply>

Here error path is an instance identifier. In libnetconf2 error path is of type string.

Thanks, Prdp Some errors in errs.txt

Prdp2710 avatar Jul 20 '20 09:07 Prdp2710

Hi, this is quite an advanced customization that you requested and we do not support that. You should be able to use the native YANG errors but it seems you even want to use an extension here. It would require quite an elaborate callback mechanism and we just do not have the time required to implement this. However, we would accept a patch provided it is clean and well-written.

Regards, Michal

michalvasko avatar Jul 27 '20 08:07 michalvasko