using Dalamud.Plugin;
 using Dalamud.Plugin.Ipc;
 using Dalamud.Plugin.Ipc.Exceptions;
+using JetBrains.Annotations;
 using Microsoft.Extensions.Logging;
 using Questionable.Controller.Steps;
 
     private readonly ICallGateSubscriber<object> _test;
     private readonly ICallGateSubscriber<string, string, string, Guid?> _registerForLeaseWithCallback;
     private readonly ICallGateSubscriber<Guid, object> _releaseControl;
-    private readonly ICallGateSubscriber<Guid,bool,object> _setAutoRotationState;
-    private readonly ICallGateSubscriber<Guid,object> _setCurrentJobAutoRotationReady;
+    private readonly ICallGateSubscriber<Guid,bool,ESetResult> _setAutoRotationState;
+    private readonly ICallGateSubscriber<Guid,ESetResult> _setCurrentJobAutoRotationReady;
     private readonly ICallGateProvider<int, string, object> _callback;
 
     private Guid? _lease;
         _registerForLeaseWithCallback =
             pluginInterface.GetIpcSubscriber<string, string, string, Guid?>("WrathCombo.RegisterForLeaseWithCallback");
         _releaseControl = pluginInterface.GetIpcSubscriber<Guid, object>("WrathCombo.ReleaseControl");
-        _setAutoRotationState = pluginInterface.GetIpcSubscriber<Guid, bool, object>("WrathCombo.SetAutoRotationState");
+        _setAutoRotationState = pluginInterface.GetIpcSubscriber<Guid, bool, ESetResult>("WrathCombo.SetAutoRotationState");
         _setCurrentJobAutoRotationReady =
-            pluginInterface.GetIpcSubscriber<Guid, object>("WrathCombo.SetCurrentJobAutoRotationReady");
+            pluginInterface.GetIpcSubscriber<Guid, ESetResult>("WrathCombo.SetCurrentJobAutoRotationReady");
 
         _callback = pluginInterface.GetIpcProvider<int, string, object>($"{CallbackPrefix}.WrathComboCallback");
         _callback.RegisterAction(Callback);
             {
                 _logger.LogDebug("Wrath combo lease: {Lease}", _lease.Value);
 
-                _setAutoRotationState.InvokeAction(_lease.Value, true);
-                _setCurrentJobAutoRotationReady.InvokeAction(_lease.Value);
+                ESetResult autoRotationSet = _setAutoRotationState.InvokeFunc(_lease.Value, true);
+                if (!autoRotationSet.IsSuccess())
+                {
+                    _logger.LogError("Unable to set autorotation state");
+                    Stop();
+                    return false;
+                }
+
+                ESetResult currentJobSetForAutoRotation = _setCurrentJobAutoRotationReady.InvokeFunc(_lease.Value);
+                if (!currentJobSetForAutoRotation.IsSuccess())
+                {
+                    _logger.LogError("Unable to setr current job for autorotation");
+                    Stop();
+                    return false;
+                }
+
                 return true;
             }
             else
         Stop();
         _callback.UnregisterAction();
     }
+
+    [PublicAPI]
+    public enum ESetResult
+    {
+        Okay = 0,
+        OkayWorking = 1,
+
+        IpcDisabled = 10,
+        InvalidLease = 11,
+        BlacklistedLease = 12,
+        Duplicate = 13,
+        PlayerNotAvailable = 14,
+        InvalidConfiguration = 15,
+        InvalidValue = 16,
+    }
+}
+
+internal static class WrathResultExtensions
+{
+    public static bool IsSuccess(this WrathComboModule.ESetResult result)
+    {
+        return result is WrathComboModule.ESetResult.Okay or WrathComboModule.ESetResult.OkayWorking;
+    }
 }