YANG Model: How to Solve

1.grouping errors Codes

grouping errors {

       description
         "A grouping that contains a YANG container
          representing the syntax and semantics of a
          YANG Patch errors report within a response message.";

       container errors {
         config false;  // needed so list error does not need a key
         description
           "Represents an error report returned by the server if
            a request results in an error.";

         list error {
           description
             "An entry containing information about one
              specific error that occurred while processing
              a RESTCONF request.";
           reference "RFC 6241, Section 4.3";

           leaf error-type {
             type enumeration {
               enum transport {
                 description "The transport layer";
               }
               enum rpc {
                 description "The rpc or notification layer";
               }
               enum protocol {
                 description "The protocol operation layer";
               }
               enum application {
                 description "The server application layer";
               }
             }
             mandatory true;
             description
               "The protocol layer where the error occurred.";
           }

           leaf error-tag {
             type string;
             mandatory true;
             description
               "The enumerated error tag.";
           }

           leaf error-app-tag {
             type string;
             description
               "The application-specific error tag.";
           }

           leaf error-path {
             type data-resource-identifier;
             description
               "The target data resource identifier associated
                with the error, if any.";
           }
           leaf error-message {
             type string;
             description
               "A message describing the error.";
           }

           container error-info {
              description
                "A container allowing additional information
                 to be included in the error report.";
              // arbitrary anyxml content here
           }
         }
       }
     } 

2. Interpretation of defined nodes

Meaning of each field in the message:
(1) error type: defines that the error occurs at the protocol level. There are four values: transport transport layer, RPC remote process call, protocol layer and application layer.
(2) error tag: identifies the content of error information.
(3) Error app tag: identifies a specific error condition. For a special error condition, this element will not appear if there is no appropriate association with it.
(4) error path: identifies the location and specific file name of the error.
(5) error message: describes the error content.
(6) Error Info: contains protocol or data model specific error content. For a special error situation, this element will not appear if appropriate information is not provided.

3. Examples

<?xml version="1.0" encoding="utf-8"?>
 <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="3">
  <rpc-error>
   <error-type>application</error-type>
   <error-tag>bad-element</error-tag>
   <error-severity>error</error-severity>
   <error-app-tag>43</error-app-tag>
   <error-path xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
	  xmlns:acl="http://xxxxx">xxxxxxxx</error-path>
   <error-message xml:lang="en">xxxxxx</error-message>
   <error-info>
    <bad-element>xxxxxxx</bad-element>
  </error-info>
 </rpc-error>
</rpc-reply>

Read More: