@@ -265,15 +265,23 @@ public void queue() throws IllegalStateException {
265265 // check if a global effect is running
266266 TimedEffect globalActiveEffect = ACTIVE_EFFECTS .get (globalKey );
267267 if (globalActiveEffect != null && !globalActiveEffect .isComplete ()) {
268- request .buildResponse ().type (Response .ResultType .RETRY ).message ("Timed effect is already running" ).send ();
268+ try {
269+ request .buildResponse ().type (Response .ResultType .RETRY ).message ("Timed effect is already running" ).send ();
270+ } catch (Exception e ) {
271+ logger .error ("Failed to send retry response" , e );
272+ }
269273 return ;
270274 }
271275
272276 // check if a per-streamer effect is running (on any targeted streamer)
273277 for (MapKey mapKey : mapKeys ) {
274278 TimedEffect activeEffect = ACTIVE_EFFECTS .get (mapKey );
275279 if (activeEffect != null && !activeEffect .isComplete ()) {
276- request .buildResponse ().type (Response .ResultType .RETRY ).message ("Timed effect is already running" ).send ();
280+ try {
281+ request .buildResponse ().type (Response .ResultType .RETRY ).message ("Timed effect is already running" ).send ();
282+ } catch (Exception e ) {
283+ logger .error ("Failed to send retry response" , e );
284+ }
277285 return ;
278286 }
279287 }
@@ -301,7 +309,11 @@ private void start() {
301309 response = callback .apply (this );
302310 } catch (Throwable exception ) {
303311 logger .error ("Exception occurred during starting callback" , exception );
304- request .buildResponse ().type (Response .ResultType .FAILURE ).message ("Requested effect failed to execute" ).send ();
312+ try {
313+ request .buildResponse ().type (Response .ResultType .FAILURE ).message ("Requested effect failed to execute" ).send ();
314+ } catch (Exception e ) {
315+ logger .error ("Failed to send failure response" , e );
316+ }
305317
306318 duration = -1 ;
307319 if (blocksOthers ) {
@@ -330,7 +342,11 @@ private void start() {
330342 future = EXECUTOR .schedule (() -> complete (), duration , TimeUnit .MILLISECONDS );
331343 }
332344
333- response .send ();
345+ try {
346+ response .send ();
347+ } catch (Exception e ) {
348+ logger .error ("Failed to send start response" , e );
349+ }
334350 }
335351
336352 /**
@@ -364,7 +380,11 @@ public void pause() throws IllegalStateException { // TODO: change to boolean re
364380 }
365381
366382 paused = true ;
367- request .buildResponse ().type (Response .ResultType .PAUSED ).timeRemaining (duration ).send ();
383+ try {
384+ request .buildResponse ().type (Response .ResultType .PAUSED ).timeRemaining (duration ).send ();
385+ } catch (Exception e ) {
386+ logger .error ("Failed to send pause response" , e );
387+ }
368388 }
369389
370390 /**
@@ -391,7 +411,11 @@ public void resume() throws IllegalStateException {
391411
392412 paused = false ;
393413 startedAt = System .currentTimeMillis ();
394- request .buildResponse ().type (Response .ResultType .RESUMED ).timeRemaining (duration ).send ();
414+ try {
415+ request .buildResponse ().type (Response .ResultType .RESUMED ).timeRemaining (duration ).send ();
416+ } catch (Exception e ) {
417+ logger .error ("Failed to send resumed response" , e );
418+ }
395419 future = EXECUTOR .schedule (() -> complete (), duration , TimeUnit .MILLISECONDS );
396420 }
397421
@@ -439,7 +463,11 @@ public boolean complete(boolean executeCompletionCallback) throws IllegalStateEx
439463 }
440464 }
441465
442- request .buildResponse ().type (Response .ResultType .FINISHED ).send ();
466+ try {
467+ request .buildResponse ().type (Response .ResultType .FINISHED ).send ();
468+ } catch (Exception e ) {
469+ logger .error ("Failed to send finished response" , e );
470+ }
443471 if (executeCompletionCallback && completionCallback != null ) {
444472 try {
445473 completionCallback .accept (this );
0 commit comments