@@ -183,24 +183,42 @@ func handleMessageEvent(state *internalState, data []byte) (err error) {
183183
184184 data , marshalError := json .Marshal (response )
185185 if marshalError != nil {
186+ if response .Err () != nil {
187+ log .WithFields (logrus.Fields {
188+ "commandName" : response .GetCommandName (),
189+ "commandId" : response .GetCommandId (),
190+ "error" : response .Err ().Error (),
191+ "marshalError" : marshalError ,
192+ }).
193+ Error ("cannot marshal MesosCommandResponse for sending as MESSAGE" )
194+ } else {
195+ log .WithFields (logrus.Fields {
196+ "commandName" : response .GetCommandName (),
197+ "commandId" : response .GetCommandId (),
198+ "marshalError" : marshalError ,
199+ }).
200+ Error ("cannot marshal MesosCommandResponse for sending as MESSAGE" )
201+ }
202+ return
203+ }
204+
205+ _ , _ = state .cli .Send (context .TODO (), calls .NonStreaming (calls .Message (data )))
206+ if response .Err () != nil {
186207 log .WithFields (logrus.Fields {
187208 "commandName" : response .GetCommandName (),
188209 "commandId" : response .GetCommandId (),
210+ "taskId" : response .TaskId ,
189211 "error" : response .Err ().Error (),
190- "marshalError" : marshalError ,
191212 }).
192- Error ("cannot marshal MesosCommandResponse for sending as MESSAGE" )
193- return
213+ Trace ("response sent" )
214+ } else {
215+ log .WithFields (logrus.Fields {
216+ "commandName" : response .GetCommandName (),
217+ "commandId" : response .GetCommandId (),
218+ "taskId" : response .TaskId ,
219+ }).
220+ Trace ("response sent" )
194221 }
195-
196- _ , _ = state .cli .Send (context .TODO (), calls .NonStreaming (calls .Message (data )))
197- log .WithFields (logrus.Fields {
198- "commandName" : response .GetCommandName (),
199- "commandId" : response .GetCommandId (),
200- "taskId" : response .TaskId ,
201- "error" : response .Err ().Error (),
202- }).
203- Trace ("response sent" )
204222 }()
205223
206224 case "MesosCommand_Transition" :
@@ -244,24 +262,42 @@ func handleMessageEvent(state *internalState, data []byte) (err error) {
244262
245263 data , marshalError := json .Marshal (response )
246264 if marshalError != nil {
247- log .WithFields (logrus.Fields {
248- "commandName" : response .GetCommandName (),
249- "commandId" : response .GetCommandId (),
250- "error" : response .Err ().Error (),
251- "marshalError" : marshalError ,
252- }).
253- Error ("cannot marshal MesosCommandResponse for sending as MESSAGE" )
265+ if response .Err () != nil {
266+ log .WithFields (logrus.Fields {
267+ "commandName" : response .GetCommandName (),
268+ "commandId" : response .GetCommandId (),
269+ "error" : response .Err ().Error (),
270+ "marshalError" : marshalError ,
271+ }).
272+ Error ("cannot marshal MesosCommandResponse for sending as MESSAGE" )
273+ } else {
274+ log .WithFields (logrus.Fields {
275+ "commandName" : response .GetCommandName (),
276+ "commandId" : response .GetCommandId (),
277+ "marshalError" : marshalError ,
278+ }).
279+ Error ("cannot marshal MesosCommandResponse for sending as MESSAGE" )
280+ }
254281 return
255282 }
256283
257284 _ , _ = state .cli .Send (context .TODO (), calls .NonStreaming (calls .Message (data )))
258- log .WithFields (logrus.Fields {
259- "commandName" : response .GetCommandName (),
260- "commandId" : response .GetCommandId (),
261- "error" : response .Err ().Error (),
262- "state" : response .CurrentState ,
263- }).
264- Trace ("response sent" )
285+ if response .Err () != nil {
286+ log .WithFields (logrus.Fields {
287+ "commandName" : response .GetCommandName (),
288+ "commandId" : response .GetCommandId (),
289+ "error" : response .Err ().Error (),
290+ "state" : response .CurrentState ,
291+ }).
292+ Trace ("response sent" )
293+ } else {
294+ log .WithFields (logrus.Fields {
295+ "commandName" : response .GetCommandName (),
296+ "commandId" : response .GetCommandId (),
297+ "state" : response .CurrentState ,
298+ }).
299+ Trace ("response sent" )
300+ }
265301 }()
266302
267303
0 commit comments