This article describes how to set a custom Error message in case the EDIT callback reports an error.

For example, assume we have the following simplified but functional YANG module and we are making a SIL-SA code for this module as follow:

> make_sil_sa_dir error-example --sil-edit2 --sil-get2

module error-example {
  namespace "";
  prefix "err";

  revision 2021-11-19 {
      "Example module";

  container test-silsa-errors {                      // EDIT2 CB
    presence "Presence";

    leaf test-error {
      type string;

In order to set a custom Error Message to be sent to the server the following API can be used:

/* Typedef of the Set Error Message API */
    sil_sa_set_error_msg (rpc_msg_t *msg,
                          const xmlChar *strval)


Assume the SIL-SA code reports an error in case the test-error leaf creation and when the value of a new leaf is force-error.

In this case there is an API sil_sa_set_error_msg() to set up a custom error to be returned to the server.

            if (child_val &&
                !xml_strcmp(VAL_STR(child_val), (const xmlChar *)"force-error")) {

                /* TRIGGER ERROR */
                res = ERR_NCX_OPERATION_NOT_SUPPORTED;

                                     (const xmlChar *)"SOME CUSTOM ERROR MSG");

Thus, as a result of the following operation the SIL-SA agent will produce an error with a custom error message:

      <test-silsa-errors xmlns="">

After the final <commit> operation the SIL-SA code will be invoked and the SIL-SA code will return an error to the server with a custom error message as can be seen in the following log from the server:

agt_ycontrol: Got <ycontrol> message:
yctl:ycontrol {
  message-id 4
  message-type subsys-response
  server-id server1
  subsys-id subsys1
  service-id sil-sa
  error {
    error-number 273
    transaction-id 1476838
    error-message 'SOME CUSTOM ERROR MSG'
    error-index 1

ycontrol_msg: sending server-event # 5 for sil-sa
ses_msg: send 1.1 buff:479for s:3


<?xml version="1.0" encoding="UTF-8"?>
<ycontrol xmlns="">
  <sil-sa xmlns="">
agt_sil: send <cancel-transaction> to subsys 'subsys1' OK
agt_top: end dispatch yumaworks-ycontrol:ycontrol
ses_msg: free msg 0x7f70ac000f90 for session 3
ycontrol_mode_done for TXID '1476838'
agt_val: exit ncxserver YControl mode
agt_record_error for session 5:
agt_val: remote SIL commit phase failed (operation not supported)
agt_val: Finished remote SIL commit phase

Start full rollback of transaction 1476838: 1 edit on running config
Rollback transaction 1476838, create edit on error-example:test-silsa-errors
SIL-SA Rollback Complete callbacks OK
agt_sil: end transaction NULL txcb
ses_msg: send 1.0 buff:412 for s:5

Content-Type: application/json
Status: 501 Not Implemented
Cache-Control: no-cache
Pragma: no-cache

 "ietf-restconf:errors": {
  "error": [
    "error-message":"SOME CUSTOM ERROR MSG",
    "error-info": {
agt_cb: Enter run_command_complete
agt_cb: Enter run_trans_complete

For complete example SIL-SA code, refer to the attachments.