code: private static void sendErrorToCallback(EventCallBackStruct cs, String callbackKey, DevFailed e) {
  
          int source = (cs.consumer instanceof NotifdEventConsumer)?
                  EventData.NOTIFD_EVENT : EventData.ZMQ_EVENT;
          EventData eventData =
                  new EventData(cs.device, callbackKey,
                          cs.event_name, source,
                          cs.event_type, null, null, null, null, null, e.errors);
  
          if (cs.use_ev_queue) {
              EventQueue ev_queue = cs.device.getEventQueue();
              ev_queue.insert_event(eventData);
          } else
              cs.callback.push_event(eventData);
      }
docs: ===============================================================